AM Modulation Digital Signal
Вставка
- Опубліковано 6 лис 2024
- AM Modulate and demodulate with digital signal.
Using an Arduino board to display received UART serial data.
Android App: Serial USB Terminal
Arduino board: UNO R3
Use ASCII table: www.asciitable...
Arduino code
int incomingByte = 0; // for incoming serial data
void setup() {
// put your setup code here, to run once:
pinMode(5, OUTPUT); //Red LED
pinMode(6, OUTPUT); //Green LED
pinMode(7, OUTPUT); //Blue LED
digitalWrite(5, LOW); //Turn off Red LED
digitalWrite(6, LOW); //Turn off Green LED
digitalWrite(7, LOW); //Turn off Blue LED
Serial.begin(2400); //Baud rate 2400bps
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() greaterthan 0) {
// read the incoming byte:
incomingByte = Serial.read();
}
if(incomingByte == 'r'){
digitalWrite(5, HIGH); //Turn on Red LED
digitalWrite(6, LOW); //Turn off Green LED
digitalWrite(7, LOW); //Turn off Blue LED
}
if(incomingByte == 'g'){
digitalWrite(5, LOW); //Turn off Red LED
digitalWrite(6, HIGH); //Turn on Green LED
digitalWrite(7, LOW); //Turn off Blue LED
}
if(incomingByte == 'b'){
digitalWrite(5, LOW); //Turn off Red LED
digitalWrite(6, LOW); //Turn off Green LED
digitalWrite(7, HIGH); //Turn on Blue LED
}
if(incomingByte == 'w'){
digitalWrite(5, HIGH); //Turn on Red LED
digitalWrite(6, HIGH); //Turn on Green LED
digitalWrite(7, HIGH); //Turn on Blue LED
}
if(incomingByte == '0'){
digitalWrite(5, LOW); //Turn on Red LED
digitalWrite(6, LOW); //Turn on Green LED
digitalWrite(7, LOW); //Turn on Blue LED
}
}