Documente Academic
Documente Profesional
Documente Cultură
What is Arduino?
Arduino is a tool for making computers that can sense and control more of the physical world
than your desktop computer. It's an open-source physical computing platform based on a
simple microcontroller board, and a development environment for writing software for the
board.
Arduino can be used to develop interactive objects, taking inputs from a variety of switches
or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino
projects can be stand-alone, or they can communicate with software running on your
computer (e.g. Flash, Processing, MaxMSP.) The boards can be assembled by hand or
purchased preassembled; the open-source IDE can be downloaded for free.
Why Arduino?
1.
2.
3.
4.
5.
Arduinos Family
UNO
Leonardo
Due
Yun
Mega
ADK
Mega
2560
Ethernet
Esplora
Nano
Pro Mini
Lilypad
Lilypad
Simple
Arduino
UNO R3
Jumper wire
Red LED
Resistor
330ohm
Buzzer
Yellow LED
Button
Photoresistor
Green LED
Temperature
Sensor (LM35)
Potentiometer
RGB
Relay
Transistor
P2N2222
LCD 1602
Servo motor
Arduino UNO
Digital Pin
Power Input
Analog Pin
Summary
Microcontroller
Operating Voltage
Input Voltage (recommended)
Input Voltage (limits)
Digital I/O Pins
Analog Input Pins
DC Current per I/O Pin
DC Current for 3.3V Pin
Flash Memory
SRAM
EEPROM
Clock Speed
ATmega328
5V
7-12V
6-20V
14 (of which 6 provide PWM output)
6
40 mA
50 mA
32 KB (ATmega328) of which 0.5 KB used by bootloader
2 KB (ATmega328)
1 KB (ATmega328)
16 MHz
TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire
library.
AREF. Reference voltage for the analog inputs.
Reset. Bring this line LOW to reset the microcontroller.
Ground (gnd)
Voltage (vcc)
Breadboard
Verify
Upload
Open
11. Now you can start do the tutorial given below, Enjoy it !
BLINK LED
Led blinking 1 second (1 second ON, 1 second OFF, then repeat)
Parts required
1. Red LED x 1
2. Resistor 330ohm x 1
3. Jumper wires
PUSH BUTTON
Parts required
1. Push button x 1
2. Resistor 330ohm x 1
3. Resistor 10kohm x 1
4. Jumper wires
BUZZER
Create the melody using the coding given. Make the tone faster and slower.
Parts required
1. Buzzer
2. Jumper wires
PHOTORESISTOR
Parts required
1. Red led x 1
2. Photoresistor x 1
3. Resistor 330ohm x 1
4. Resistor 10kohm x 1
5. Jumper wires
//photoresistor
int photoPin = 1; // select the input pin for the photoresistor
int ledPin = 13; // select the pin for the LED
int val; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(photoPin); // read the value from the sensor
Serial.println(val);
//val=map(val, 0, 1023,0, 255); // val=map(variable, min, max,0, 255);
analogWrite(ledPin, val); // turn the ledPin brightness
}
POTENTIOMETER
Control the LED brightness
Parts required
1. Potentiometer x 1
2. Red LED
3. Jumper wire
//potentiometer
int potPin = 0; // select the input pin for the potentiometer
int ledPin = 11; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
Serial.println(val);
val=map(val, 0, 1023,0, 255);
analogWrite(ledPin, val); // turn the ledPin brightness
}
RGB
Parts required
1. RGB
2. Resistor 330ohm
3. Jumper wires
//Coding
int ledcolor = 0;
int a = 1000; //this sets how long the stays one color for
int red = 11; //this sets the red led pin
int green = 10; //this sets the green led pin
int blue = 9; //this sets the blue led pin
void setup() { //this sets the output pins
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop() {
int ledcolor = random(7); //this randomly selects a number between 0 and 6
switch (ledcolor) {
case 0: //if ledcolor equals 0 then the led will turn red
analogWrite(red, 51);
delay(a);
analogWrite(red, 255);
break;
case 1: //if ledcolor equals 1 then the led will turn green
digitalWrite(green, LOW);
delay(a);
digitalWrite(green, HIGH);
break;
case 2: //if ledcolor equals 2 then the led will turn blue
digitalWrite(blue, LOW);
delay(a);
digitalWrite(blue, HIGH);
break;
case 3: //if ledcolor equals 3 then the led will turn yellow
analogWrite(red, 95);
digitalWrite(green, LOW);
delay(a);
analogWrite(red, 255);
digitalWrite(green, HIGH);
break;
case 4: //if ledcolor equals 4 then the led will turn cyan
analogWrite(red, 168);
digitalWrite(blue, LOW);
delay(a);
analogWrite(red, 255);
digitalWrite(blue, HIGH);
break;
case 5: //if ledcolor equals 5 then the led will turn magenta
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
delay(a);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
break;
case 6: //if ledcolor equals 6 then the led will turn white
analogWrite(red, 155);
digitalWrite(green, LOW);
digitalWrite(blue, LOW);
delay(a);
analogWrite(red, 255);
digitalWrite(green, HIGH);
digitalWrite(blue, HIGH);
break;
}
}
TEMPERATURE SENSOR
Display the environment temperature in Serial monitor
Parts required
1. Temperature Sensor LM35 x 1
2. Jumper wires
//temperature
float temp;
int tempPin = 2;
int led = 2;
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
}
void loop()
{
temp = analogRead(tempPin);
temp = temp * 0.48828125;
if(temp>27){
digitalWrite(led,HIGH);
}
else{
digitalWrite(led,LOW);
}
Serial.print("TEMPERATURE = ");
Serial.print(temp);
Serial.print(char(176));
Serial.print("C");
Serial.println();
delay(1000);
}
RELAY
Parts required
1. Green LED
2. Yellow LED
3. Relay
4. Transistor P2N2222
5. Resistor 330ohm
6. Diode 1N4148
7. Jumper wire
int relayPin = 4;
SERVO MOTOR
Sweep servo motor from 0o to 180o and back to 0o, then repeat again.
Parts required
1. Servo motor
2. Jumper wire
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{
// in steps of 1 degree
myservo.write(pos);
// tell servo to go to position in variable 'pos'
delay(15);
// waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos);
// tell servo to go to position in variable 'pos'
delay(15);
// waits 15ms for the servo to reach the position
}
}
LCD 1602
Parts required
1. LCD 1602
2. Potentiometer
3. Jumper wires
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
Task 1
TRAFFIC LIGHT
Please develop traffic light led blinking using three different led colour. Start with green led,
followed by yellow and red led.
Task 2
WARNING LED
Develop a code to turn on led after the sensor reach more than 30 degrees.
Parts required
1. Red LED x 1
2. Resistor 330ohm x 1
3. Temperature sensor LM35 x 1
4. Jumper wire
Task 3
TEMPERATURE LCD DISPLAY