Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int ledPin = 13; // the pin that the LED is attached to
- int tx=1;
- int rx=0;
- int val=0;
- void setup()
- {
- // initialize the serial communication:
- Serial.begin(9600); //baud rate - make sure it matches that of the module you got:
- pinMode(tx, OUTPUT);
- pinMode(rx, INPUT);
- digitalWrite(ledPin, LOW);// initialize the ledPin as an output:
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- if (Serial.available() > 0) {
- val = Serial.read();
- Serial.println(val);}
- switch (val) {
- case 0:
- digitalWrite(ledPin, LOW);
- break;
- case 1:
- digitalWrite(ledPin,HIGH);
- break;
- case 2:digitalWrite(ledPin, HIGH);
- delay(100);
- digitalWrite(ledPin, LOW);
- delay(100);
- default:
- break;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement