Using Serial Communication
Method used to transfer data between two devices.
Serial Monitor & analogRead()
Sending a Message
void setup()
{
// initialize serial:
Serial.begin(9600);
}
void loop ( )
{
Serial.print(“Hands on ”) ;
Serial.print(“Learning ”) ;
Serial.println(“is Fun!!!”) ;
}
Homework Exercise
- Modify your program such that
- When the switch is off
- The message OFF is repeatedly printed via Serial, and the system will not do anything else
- When the switch is on
- The LED will gradually turn on or off at a speed which is related to the amount of light failing on the LDR
- The message ON is repeatedly printed via Serial
- When the switch is off
- Use a Serial bit/baud rate of 115200 instead of 9600 for the above