Posts

Showing posts from January, 2019

Lesson 6: Potentionmeter & LED

Image
This lesson is about a Controlled LED brightness using   Potentiometer .  In our model, the brightness of the LED will depend on the rotation of the  potentiometer  knob. This is also one of the basic schemes. Link to original lesson: http://edurobots.ru/2014/04/arduino-potenciometr/ Hardware parts for this lesson: Arduino board Breadboard LED 220 Ohm resistor Jumpers (wires) Potentiometer Scheme on breadboard: Program code for this project: #define led 9 #define pot A0 void setup(){ pinMode(led, OUTPUT); pinMode(pot, INPUT);         Serial.begin(9600); } void loop(){ int x; // read value of Potentiometer // as you remember A0-A5 pins working in range of 0-1023 // but analog INPUT/OUTPUT pins range is 0-255 // to get correct result we will divide result to 4 x = analogRead(pot) / 4;         Serial.print("X=");         Serial.println(x); // show result on LED analogWrite(led, x); } Task for Advanced students: Giv

Lesson 5: Potentiometer

Image
A  potentiometer  is a variable resistor with adjustable resistance.  Potentiometers  are used in robotics as regulators of various parameters - volume of sound, power, voltage, etc.  In this lesson we will connect potentiometer to Arduino, and look to its signal values through 'Serial monitor'. Scheme on breadboard: Upload this code, and open 'Serial Monitor' in Arduino IDE application. Then rotate Potentiometer to see changes: void setup() {   //initialize A0 port as INPUT   pinMode(A0, INPUT);   //initialize Serial port to 9600   Serial.begin(9600); } void loop() {   //print the result of Potentiometer in Serial monitor   Serial.println(analogRead(A0));   //wait 2 seconds   delay(2000); }

Lesson 4: Traffic light control

Image
Like in Lesson 2 you'll need to make Traffic light project. But there will be one small difference: we need to add 3 buttons, to control lights (red, yellow, green). Hardware parts for this lesson: Arduino board Breadboard LED, 3 pieces 220 Ohm Resistors, 3 pieces Jumpers Buttons, 3 pieces 10K Ohm Resistors, 3 pieces Give time to students to write a code. After construction of the model, you give 10 minutes to finish the code. And in the end show your version of code: int b1 = 2; int b2 = 3; int b3 = 4; int led1 = 11; int led2 = 12; int led3 = 13; void setup() {     pinMode(led1, OUTPUT);     pinMode(led2, OUTPUT);   pinMode(led3, OUTPUT);     pinMode(b1, INPUT);   pinMode(b2, INPUT);   pinMode(b3, INPUT); } void loop(){     if (digitalRead(b1) == HIGH) {             digitalWrite(led1, HIGH);     }     else if(digitalRead(b2) == HIGH){             digitalWrite(led2, HIGH);     }   else if(digitalRead(b3)