| Home | | Weekly Assignments | | Final Project | | Photo Gallery |

Week 15 - Networking and Communications.
Assignment
This week's assignment is to establish communication between two boards. The idea of doing this exercise is to learn how two devices communcate with each other. I would be mainly focusing on establising communication between any of the two boards I created. I am planning on to make another board to connect a PIR sensor for my final Assignment.
The Plan
Here I would be establising communication between the LED board with button which I created in the embedded programming week (week 8) and the board I made to connect a PIR sensor for my final project.
My assignment will be completed if I can succesfully make a dc motor connected to the second board work by pressing a button on the first board.
Making the boards
The designing and making of baord one can be found in my week 8 The second board to be used for serial communication was designed in Kokopelli.

This board is made to connect a servo with a PIR sensor and also to be used for doing this assignment.

Milled the board using Roland MDX 20 through Fab Modules on Ubuntu.

Now the second board is ready.
Now I have to connect the board and establish communication between two boards. I had trouble connecting the boards with each other and finally I figured a way around.

The communication takes place between two pins of each board. receiver, RX, and the transmitter, TX. So the RX from one board should go to the TX of the board, and vice-versa.

These two boards shall be connected with each other to establish a network communication.

I connected RX and TX of each board with each other. Added power supply to the first board and added a dc motor to the analog pin and gnd of the second board. Now I need to program it in such a way that if I press the button on the first board, The dc motor connected to the second board starts working.
Code uploaded to the board with dc motor:
#includeCode uploaded to the board with button:SoftwareSerial mySerial(0,1); char data; const int motorPin = 4; void setup() { mySerial.begin(9600); pinMode(motorPin, OUTPUT); } void loop() { data = mySerial.read(); if (data == '1') { digitalWrite(motorPin, HIGH); // Debug if the data check works mySerial.print("ok"); } else { digitalWrite(motorPin, LOW); } delay(100); }
#includeSoftwareSerial mySerial(0,1); const int buttonPin = 6; int buttonState = 0; void setup() { mySerial.begin(9600); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); digitalWrite(buttonPin,HIGH); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == LOW) { mySerial.print('0'); delay(100), mySerial.print('1'); delay(100); } }
Output video:
Files:
djpro.png
djprointerior.png
djprotraces.png
clone.ino
test.ino