Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* controlling pins on a port via Serial */
- byte incomingByte = 0; // variable for incoming serial data
- void setup() {
- Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
- DDRB= B00111111; //Set Port B as output (Pins 8 to 13) Two MSB pins are for Xtal and unusable
- }
- void loop() {
- // Listen for incoming Serial data:
- if (Serial.available() > 0) {
- // read the incoming byte:
- incomingByte = Serial.read(); //Read from Serial Port
- PORTB=incomingByte; //output data to Port B
- /* so, if you send 8 to serial,Port B will become 00010000
- send 3 Port B will become 00000011
- send 2 Port B will become 00000010
- send 6 Port B will become 00000110
- send 255 Port B will become (xx)111111
- and so on
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement