Академический Документы
Профессиональный Документы
Культура Документы
Tools:
Arduino IDE, Proteousetc
Apparatus:
Arduino IDE, Proteus,Resistor, LED
Theory:
Introduction:
Serial communication works on 1s and 0s. Also known as binary, the Arduino
sends these 1s and 0s (bits) one by one, or Serially. These bits are sent in the
form of Highs(1) and Lows(0). These bits form together and turn into bytes. A
byte
is
composed
of
8
bits.
Each bit represents a certain number to add. the first bit (Far right)
represents
the
ones
place,
1 = 1 and 0 = 0. Serial is used for communication between the Arduino
board and a computer or other devices. All Arduino boards have at least one
serial port (also known as a UART or USART): Serial. It communicates on
digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if
you use these functions, you cannot also use pins 0 and 1 for digital input or
output.
Procedure:
Lab Task:
Serial Communication With Atmega328p/Arduino Uno And Testing With Hyperterminal
Screen Shoots:
Programe: (1)
char pick;
void setup() {
//put your main code here,to run once;
Serial.begin(9600);
}
void loop() {
//put your main code here,to run repeatedly;
if(Serial.available())
{
pick -Serial.read();
Serial.println("TUFIANS");
delay(1000);
Serial.write(pick);
}
}
(2)
int byteread;
void setup() {
//put your main code here,to run once;
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
//put your main code here,to run repeatedly;
if(Serial.available()>0)
{
byteread=Serial.read();
if(byteread='1')
{
digitalWrite(13,HIGH);
Serial.println("LED is on");
}
else if (byteread='0')
{
digitalWrite(13,LOW);
Serial.println("LED is OFF");
}
}
}
(3)
void setup() {
//put your main code here,to run once;
Serial.begin(9600);
}
void loop() {
//put your main code here,to run repeatedly;
Serial.write("ELECTRONICS");
delay(1000);
}
Result: