Homework due Wednesday November 1

Foreword: 

This assignment had two parts. The first asked us to control a servo with our mouse, which is very similar to the way we control the brightness of an LED. The second assignment was writing a program so that when clicking on a rectangle, your LED would turn on or off.

First part:

As we mentioned in the foreword, this is very similar to controlling the brightness of an LED. In actuality, we just have to map the angle of the servo with the brightness so that when our mouse is on the left, the brightness (and therefore the angle) is 0, which points to the left. Same thing with the highest brightness, which makes the servo point 180º.

Below there’s the code and a video:

IMG_2584

Arduino code:

Processing code

Second part:

I am not sure if the code is absolutely working because you can still turn the LED off by clicking on the same part of the square. I will try to figure out a way to avoid this, and will update the code if I find a way!

Arduino code

Processing code

 

 

Leave a Reply

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