My Viral Box Logo
Ad image
  • Funny Stories
  • Weird Stories
  • Scary Stories
  • Ghost Stories
  • Funny Riddles
  • Short Jokes
Reading: Review of the online course on Arduino / robotics from MIPT (second week)
Share
MYVIRALBOX MYVIRALBOX
Font ResizerAa
  • Funny Stories
  • Weird Stories
  • Funny Riddles
  • Ghost Stories
  • Scary Stories
Search
  • Funny Stories
  • Weird Stories
  • Scary Stories
  • Ghost Stories
  • Funny Riddles
  • Short Jokes
Have an existing account? Sign In
Follow US
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
MYVIRALBOX > Funny Stories > Review of the online course on Arduino / robotics from MIPT (second week)
Funny StoriesWeird Stories

Review of the online course on Arduino / robotics from MIPT (second week)

MVB Staff
Last updated: April 25, 2024 3:36 pm
MVB Staff
Published: April 12, 2017
Share
8 Min Read
SHARE

Arduino

We continue publishing the online course “Building robots and other devices on Arduino”, starting here.

So, for a long time, the second week of the online course of robotics from MIPT ended. To admit, the week turned out to be very full of all sorts of topics.

Here is an indicative list, which I singled out for myself:

  • Voltage Divider. Use of photoresistor and thermistor
  • Analog signal. The bit depth of the signal
  • Communication through the serial port. Processing Environment
  • A digital signal. Buttons and connection options. The pull-up resistor
  • Logical expressions, if and else statements
  • Buzzer, LED scale, seven-segment indicator
  • Microcircuits. Logical inverter 74HC04, shift register 74HC595
  • Debugging programs
  • External Modules
  • A variant of a ready-made monitoring system that displays the temperature and the level of illumination on an LED scale, as well as a loudspeaker triggered when a certain temperature is exceeded

Having successfully passed the test and collected the proposed schemes from the lessons, I thought about how to improve this or that scheme or to collect something of my own.

The first thing that came to mind – Upgrading of the light sensor. The implementation proposed in the lesson simply removed the value from the photoresistor and sent it to the serial port.

The upgraded version should use a seven-segment indicator to output numbers from 0 (minimum illumination) to 9 (maximum illumination). The indicator must be connected via a shift register. Use the two buttons to set the minimum and maximum light levels. The shift register is needed in order not to use Arduino on each segment, but instead use a smaller number of pins. In fact, the shift register converts the serial data output (one bit per time unit) into a parallel (several bits per unit of time). In our case, instead of seven Arduino pins, we only need three.

In the Fritzing editor, I got such a device.

So it looks alive.

]

Note that the photoconductor is connected in a slightly different way on the PCB than in the video lesson – where we shot the value of the voltage on the photoresistor relative to the ground, and in the circuit we take the voltage drop with respect to Power supply. This is done to simplify the program a little – as the illumination level increases, the photoresistor resistance decreases. Consequently, at the same current, the voltage drop is reduced. Therefore, on the analog input, the higher the voltage, the higher the illumination level, and vice versa.

Now it’s up to small – to refine the source code. The program was based on the same program for deriving the value for the seven-segment indicator.

Program code

 // Pins required for the shift register operation
#define DATA_PIN 13
#define LATCH_PIN 12
#define CLOCK_PIN 11
// The pins of the buttons responsible for setting the minimum and maximum values
#define BTN_MIN 3
#define BTN_MAX 2
// Pin, from which we will take the values ​​of the photoresistor
#define SENS_PIN A5

// The values ​​of the register outputs for the indicator, corresponding to the digits
Byte d0 = 0b01111101;
Byte d1 = 0b00100100;
Byte d2 = 0b01111010;
Byte d3 = 0b01110110;
Byte d4 = 0b00100111;
Byte d5 = 0b01010111;
Byte d6 = 0b01011111;
Byte d7 = 0b01100100;
Byte d8 = 0b01111111;
Byte d9 = 0b01110111;

// Predefined minimum and maximum light levels
Int min_light = 0;
Int max_light = 1023;

// The current value of the sensor
Int value;
// Value limited to min. And max. The level of
Int output;
// Output digit
Int digit;

Void setup ()
{
// Set the shift register pins
PinMode (DATA_PIN, OUTPUT);
PinMode (CLOCK_PIN, OUTPUT);
PinMode (LATCH_PIN, OUTPUT);
// Turn on the port for debugging information
Serial.begin (9600);
// Set the pins for the buttons
PinMode (BTN_MIN, INPUT_PULLUP);
PinMode (BTN_MAX, INPUT_PULLUP);
}

Void loop ()
{
// Get the value from the photoresistor
Value = analogRead (SENS_PIN);
Output = value;

// If buttons are pressed – set threshold values
If (!, digitalRead (BTN_MIN)) min_light = value;
If (! DigitalRead (BTN_MAX)) max_light = value – 10;

// Apply top and bottom constraints
If (value < min_light) output = min_light; if (value > max_light) output = max_light;
// Get the digit that should be output to the indicator
Digit = map (value, min_light, max_light, 0, 9);

// Debug information
Serial.println (“Value:” + String (value) + “Output:” + String (output) + “Min:” + String (min_light) + “Max:” + String (max_light) + “Current:” + String (Value) + “Digit:” + String (digit));

// Output the digit directly to the indicator
If (digit == 0)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d0);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 1)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d1);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 2)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d2);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 3)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d3);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 4)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d4);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 5)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d5);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 6)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d6);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 7)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d7);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 8)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d8);
DigitalWrite (LATCH_PIN, HIGH);
}
Else if (digit == 9)
{
DigitalWrite (LATCH_PIN, LOW);
ShiftOut (DATA_PIN, CLOCK_PIN, LSBFIRST, d9);
DigitalWrite (LATCH_PIN, HIGH);
}
// Delay for smoother output
Delay (10);
From the features – when setting the maximum level of illumination, we had to subtract a certain constant (max_light = value – 10), selected empirically. This is necessary in order to avoid “rattling” at the maximum level of illumination, since the value of the voltage taken from the photoresistor is unstable.

We compile the sketch, load it into Arduino and check it.

The monitor of the port …

And then live

MVB Staff
MVB Staff

You Might Also Like

The Beehive Nightmare: A Mother’s Shocking Discovery
Calf’s human-like face shocks onlookers
How to assemble the audio system from broken speakers and amplifier from flea markets / Geektimes
Unexpected Lottery: Michigan Woman Wins Big After Car Wash Stop
Windows Says “Nope!” Millions Left Staring at the Blue Screen of Death
Leave a Comment Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search Posts

‎‎‎‎‎Explore Our Categories

  • Funny Riddles9
  • Funny Stories525
  • Ghost Stories3
  • Scary Stories20
  • Short Jokes1
  • Weird Stories479
Ad image

Latest added

funny questions to ask
Funny Stories

120 funny questions to ask to spark laughter and break the ice

May 23, 2025
weird football rivalries
Weird Stories

Weird Football Rivalries: Strange Stories Behind the Game’s Fiercest Feuds

May 14, 2025
most dangerous football derbies
Scary Stories

7 Most Dangerous Football Derbies Worldwide: Intense Rivalries and Risks

May 13, 2025
wonderful Scottish football
Weird Stories

9 weird and wonderful Scottish football moments

May 12, 2025
Weirdest Players in Arsenal FC History
Weird Stories

14 Weirdest Players in Arsenal FC History: Strange Stories and Quirky Characters

May 11, 2025
weird football formations
Weird Stories

7 Weird Football Formations That Actually Worked

May 11, 2025

Explore More

  • Privacy Policy
  • Submit Your Silly Stories

Follow US on Social Media

Facebook Instagram Pinterest Envelope-open

My Viral Box Logo

About My Viral Box

MyViralBox brings together all the weird, wacky, scary and funny news from around the web in one place to brighten your day. You might scratch your head; you might laugh out loud; you might glance over your shoulder; but you’re gonna have fun whenever you drop by. Funny news, weird news, chill-inducing spookiness, jokes and riddles of all kinds, plus whatever else we come across that we think just has to go viral; you’ll find it all right here!

© My Viral Box. All Rights Reserved.

Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?