For my first milestone, I created a wireless network between two Arduinos, such that a servo moves if the flex sensor is bent. To accomplish this, I configured two radio Xbees to talk on the same network, and attached them to the Arduinos. I then made circuits for the servo (using an additional 6V power source) and the flex sensor on breadboards, and connected each to different Arduinos. I created code that reads the value of the flex sensor, determines whether it is above 300 or not, and so transmits a forward or reverse command through the Xbees to the Arduino, which instructs the servo to turn accordingly. Some issues I ran into getting to this milestone were problems creating the Xbee network, coding the Xbees, and a shortage the power supply for the servo’s Arduino. To create the Xbee network, I found that I needed to reset each to the factory default, enter a PAN id, set one as coordinator (which doesn’t change anything for the purposes of my project), and fill in empty boxes with zeros, without changing any other settings. When coding for the Xbee network, I realized after a deal of problems that I was using the wrong commands. By comparing my work with guides in the Arduino reference guide and past students’ work, I realized that I needed to use commands from the SoftwareSerial library and class, which involved creating instances for the each Xbee and setting its ports. I found that the servo drew too much power from the Arduino for it to handle, shutting it down automatically. To solve this, I made a circuit on a breadboard and connected a 6V external battery pack.
Here is the code I used for this milestone: