You are on page 1of 7

Open source

Accepts analog and digital signals

Based on atmega chip

We are using atmega328 chip

5v power supply

16mhz clock speed

14 digital i/o

Analog inputs-6

Programming Language-c and c++

Tools->board->uno

Program coded in arduino ide is called Sketch

Compilation-verify

Magnifying symbol-serial monitor:open serial console

All the data printed to console are displayed here

Sketch structure:

 Setup()-for intiliazing.like main() in c


 Loop()-iterates specify tasks

Data types

Void

Int Boolean

Byre

Float

Array

String-object

Long
Char

Unsigned int

Double

Save as file_name.ino

In setup() write serial.begin(9600);

Program 1:

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

void loop() {

// put your main code here, to run repeatedly:

Serial.println("hello world");

Delay method takes input as milliseconds.in loop().

Program 2:

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

void loop() {

// put your main code here, to run repeatedly:


Serial.println("hello world");

delay(1000);

pinMode(pin,mode);

pin-pin number

0-13 pins

Mode-input/output

Digital write()-writes a high or low value to digital pin

analogRead()-reads from analog i/p i.e, voltage applied.1023 for 5 volts.0 in deadspeed

character functions-isdigit(),isalpha(),isalnum(),isxdigit(),islower(),isupper(),isspace(),retrun 1(true) or


0(false)

LED_BUILTIN pin number-13

BLINK PROGRAM:

void setup() {

// initialize digital pin LED_BUILTIN as an output.

Serial.begin(9600);

pinMode(LED_BUILTIN, OUTPUT);

// the loop function runs over and over again forever

void loop() {

digitalWrite(LED_BUILTIN, HIGH);

Serial.println("ON");// turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second


digitalWrite(LED_BUILTIN, LOW);

Serial.println("OFF");// turn the LED off by making the voltage LOW

delay(1000); // wait for a second

For external led connection:

Connect long leg wire to 12 pin

And other one to ground

7/2/19
Str.ToUpperCase()

Str.rep;ace(str1,str2)

Str.length()

randomSeed(int v)-random no.s from v

random(maxi)-from 0 to maxi

random(mini,maxi)-from mini to maxi

digitalPinTointerrupt(pin)-change actual digital pin to specific interrupt number

Attachinterrupt(digitalpintointerrupt(pin),ISR,mode)

Isr-interrupt service routine

_________________________________________________________________________________

8/2/19
,
Potentiometer-middle wire to analog pin 1wire to gnd,1 wire to 5v

Output range 0 to 1023

Some pins have negation ~symbol those are called as pwm pins(pulse with modulation)

Sensor
4 pins:

1 pin-3.3v to 5v

2 pin-digital pin-12

3 pin-null

4 pin-gnd

Functions:

->dht.readHumidity()

->dht.readTemperature()

Program:

#include<DHT.h>

DHT dht(8,DHT22);

float humidity;

float temperature;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600):

dht.begin();

void loop() {

// put your main code here, to run repeatedly:

humidity=dht.readHumidity();

temperature=dht.readTemperature();

Serial.print("Humidity: ");

Serial.print(humidity);
Serial.print("%,Temperature: ");

Serial.print(temperature);

Serial.print("Celsius");

delay(2000);

#include<DHT.h>

DHT dht(8,DHT22);

float humidity;

float temperature;

void setup() {

// put your setup code here, to run once:

Serial.begin(9600):

dht.begin();

pinMode(LED_BUILTIN, OUTPUT);

void loop() {

// put your main code here, to run repeatedly:

humidity=dht.readHumidity();

temperature=dht.readTemperature();

Serial.print("Humidity: ");

Serial.print(humidity);

Serial.print("%,Temperature: ");

Serial.print(temperature);
Serial.print("Celsius");

delay(2000);

if(temperature>30)

digitalWrite(LED_BUILTIN, HIGH);

else

{digitalWrite(LED_BUILTIN, LOW);

You might also like