1. Arduino is an open-source electronics platform based
on easy-to-use hardware and software
Arduino boards are able to
i) read inputs - light on a sensor
ii) a finger on a button, or a Twitter message - and turn it into
an output
iii) activating a motor, turning on an LED
iv) publishing something online.
To do so you use the Arduino programming language (based
on Wiring), and the Arduino Software (IDE), based
on Processing.
2. The Arduino Software (IDE) allows you to write programs and
upload them to your board
Initially purchase the board, 2 pin LED, usb cable
GND
POSITIVE
4. void setup()
{
// put your setup code here, to run once:
}
void loop()
{
// put your main code here, to run repeatedly:
}
Two main blocks are there in Arduino coding
5. void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
13
// the loop function runs over and over again forever
void loop()
{
// turn the LED on (HIGH is the voltage level)
digitalWrite(LED_BUILTIN, HIGH);
delay(1000); // wait for a second
// turn the LED off by making the voltage LOW
digitalWrite(LED_BUILTIN, LOW);
delay(1000); // wait for a second
}
Code
to
blink
LED
10. Arduino relay module
Basically, a relay is an electromagnetic switch. The input side is a
coil while the output side is a switch magnetically connected to
the coil. When current flows through the coil, the switch toggles:
Four-relay module
Two-relay module
12. void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(250); // wait for a second
digitalWrite(8, LOW); // turn the LED off by making the voltage LOW
delay(250);
}
14. void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(7, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(7, HIGH);
delay(75);
digitalWrite(7, LOW);
delay(50);
}
Blinking Light on bread board