Modules For School Visit Workshop
Modules For School Visit Workshop
Modules For School Visit Workshop
By
Institute of Computer Science and Digital Innovation
(ICSDI)
Content
• Introduction to Arduino
• What is Microcontroller?
• What is development board?
• What is Arduino?
• Types of Arduino
• What is Tinkercad ?
• Activities
• LED Blinking
• Traffic Light Controller
• Automated LED Switching based on Light Intensity
• Kahoot!
• Ultrasonic Distance Sensor with Piezo (Demo only)
Introduction to Arduino
What is a Microcontroller
Arduino Uno
Arduino Nano
1 x Resistors (200Ω)
Light Emitting Diode (LEDs)
Building the circuit in Tinkercad
• In the Tinkercad Circuits components panel, drag a resistor and LED onto the
workplane.
• Edit the resistor's value by adjusting it to 200Ω in the component inspector which
appears when the resistor is selected.
• Back in the components panel, find and bring over an Arduino Uno board.
• Click once to connect a wire to a component or pin, and click again to connect the
other end.
• Connect your resistor to the LED's anode (positive, longer), connect the resistor's
other leg to Arduino's digital pin 13.
• Create another wire between the unconnected LED leg to ground.
Coding in Tinkercad
void loop()
{
digitalWrite(13, HIGH);
delay(10000); // Wait for 10000 millisecond(s)
digitalWrite(13, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
Activity 2
Traffic Light Control
Arduino UNO
3 x Resistors (200Ω)
Connection of Arduino with LEDs
Programming Code (1/2)
int red = 13;
int yellow = 12;
int green = 11;
void setup()
{
// configured red, yellow and green LEDs to be outputs.
pinMode (red, OUTPUT);
pinMode (yellow, OUTPUT);
pinMode (green, OUTPUT);
}
Programming Code (2/2)
void loop()
{
// green off, yellow on for 3 seconds
digitalWrite(green, LOW);
digitalWrite(yellow, HIGH);
delay(3000);
// turn off yellow, then turn red on for 5 seconds
digitalWrite(yellow, LOW);
digitalWrite(red, HIGH);
delay(5000);
// turn off red and yellow, then turn on green
digitalWrite(yellow, LOW);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(6000);
}
Activity 3
Automated LED switching based on light
intensity
Arduino Uno
1 LED (Yellow)
1 Photoresistor
Jumper Wires
Connection of Arduino with LED and
Photoresistor
Programming Code
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(analogRead(A0)>=903)
{
digitalWrite(13,LOW);
}
else
{
digitalWrite(13,HIGH);
}
}
Let’s Kahoot!
1 Piezo
Components 1 Resistor(330Ω)
Jumper Wires
Connection of Arduino with Buzzer and
Ultrasonic Sensor
Programming Code
const int buzzer = 8;
int echopin = 6;
int trigpin = 7;
int mesafe;
int sure;
void setup()
{
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
}
Programming Code
void loop()
{
digitalWrite(trigpin,LOW);
delayMicroseconds(2);
digitalWrite(trigpin,HIGH);
delayMicroseconds(10);
digitalWrite(trigpin,LOW);
sure = pulseIn(echopin,HIGH);
mesafe = (sure/2)/29.0;
if(mesafe <= 15)
{
digitalWrite(buzzer,HIGH);
delay(250);
digitalWrite(buzzer,LOW);
delay(125);
}
Programming Code
else if(mesafe <= 20)
{
digitalWrite(buzzer,HIGH);
delay(500);
digitalWrite(buzzer,LOW);
delay(250);
}
else if(mesafe <= 30)
{
digitalWrite(buzzer,HIGH);
delay(1000);
digitalWrite(buzzer,LOW);
delay(1000);
}
Programming Code
else
{
digitalWrite(buzzer,LOW);
}
Serial.print("uzaklik = ");
Serial.print(mesafe);
Serial.println("cm");
delay(500);
}