The purpose of Challenge 1 was to demonstrate that we are able to perform some basic functionalities with the new technology, GoPiGo. In our demonstration of the lights, the eyes of GPG blink three times then the front LEDs alternate between right and left for one second each. The left LED is slightly hidden by the hardware attached to our car. In terms of the motors, the car demonstrates forward motion by running both motors at the same speed as well as showing control of individual motors. The code for Challenge 1 can be found below.
The purpose of Challenge 2 was to demonstrate the usage of a sensor and create a response using an actuator. We decided to demonstrate proportional control using the GoPiGo in a similar manor to Project 1 earlier in the semester. The ultrasonic sensor was used to detect the wall and slow down as the car got closer to the wall and stop when it was at the desired distance, in this case any distance in between 13.8 to 14.2 cm from the wall. Anything closer than this and the car will back up. The difference in motor powers in the code is due to the fact that our car naturally drifts to the right. The inclusion of the 2.032 in the first if statement line is due to the fact that the sensor would sometimes read this distance when very far away from the wall (this is presumably some sensor error), so we added the value to the code to allow for smooth motion