Device Operation using PC by Arduino (2)
Device Operation using PC by Arduino (2)
DEVICE OPERATION
USING PC BY ARDUINO
Block Diagram
PC
Device1
Device2
ABSTRACT
RESET
SCL\SDA
(I2C Bus)
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
Technical specifications
• Microcontroller: Microchip ATmega328P [7]
• Operating Voltage: 5 Volts
• Input Voltage: 7 to 20 Volts
• Digital I/O Pins: 14 (of which 6 can provide PWM output)
• UART: 1
• I2C: 1
• SPPI: 1
• Analog Input Pins: 6
• DC Current per I/O Pin: 20 mA
• DC Current for 3.3V Pin: 50 mA
• Flash Memory: 32 KB of which 0.5 KB used by optiboot bootloader
• SRAM: 2 KB
• EEPROM: 1 KB
• Clock Speed: 16 MHz
• Length: 68.6 mm
• Width: 53.4 mm
• Weight: 25 g
Serial Communication
• Serial communication is a communication method that uses one
or two transmission lines to send and receive data, and that data
is continuously sent and received one bit at a time.
Basics of serial communication
Difference between serial and parallel
communication
Serial communication standards
Serial.print(1.23456) → “1.23”
Serial.print('N') → “N”
Serial.print("Hello”) → “Hello”
SERIAL Communication
• Serial.println() : Prints data to the serial port as humanreadable
ASCII text followed by a newline character (‘\r’ or '\n’).
• Serial.write() : Writes binary data to the serial port. It will return the
number of bytes written. To send the characters representing the
digits of a number use the print() function instead.
Ex : int bytesSent = Serial.write(“hello”);
• Serial.read() : Reads incoming serial data. It returns the first byte of
incoming serial data available (or -1 if no data is available).
Ex : var = Serial.read();
• Serial.available() : Get the number of bytes (characters) available for
reading from the serial port. It returns the number of bytes available
to read.
Ex : if(Serial.available()>0)
Software: Arduino IDE
Soft Code
int fan=2;
if(a=='@')
int light=3;
{
void setup()
Serial.println("LIGHT ON");
{
digitalWrite(light,HIGH);
pinMode(fan,OUTPUT);
}
pinMode(light,OUTPUT);
if(a=='+')
Serial.begin(9600);
{
Serial.println("PRESS");
Serial.println("fan OFF");
Serial.println("# to ON fan");
digitalWrite(fan,LOW);
Serial.println("@ to ON light");
}
Serial.println("+ to OFF fan");
if(a=='-')
Serial.println("- to OFF light");
{
}
Serial.println("light OFF");
void loop()
digitalWrite(light,LOW);
{
}
char a;
}
if(Serial.available()>0)
{
a=Serial.read();
Serial.print(a);
}
if(a=='#')
{
Serial.println("fan ON");
digitalWrite(fan,HIGH);
}
Hardware Connection using Proteus