Controlling Servo and LED Using Serial Connection [Nov. 1, 2017]

Foreword:

This assignment involved two pairs of Arduino and Processing patches both used to practise using serial connection to communicate with a microcontroller using Processing. The first one uses the mouseX location and sends it to the microcontroller. From there, in the microcontroller, the value received is mapped to a value between 0 and 180 and written to the connected servo. The second one draws two rectangles on the screen and then when the mouse is clicked a function runs to check if the position of the mouse is within one of the rectangles. Depending on which rectangle was clicked, a 1 or 0 is sent to the microcontroller. From there, in the microcontroller, the value received is used to turn the LED on or off.

Servo Code

Arduino Sketch

Processing Sketch

 

LED Code:

Arduino Sketch

Processing Sketch

 

Leave a Reply

Your email address will not be published. Required fields are marked *