This week we have been busy creating a sketch model of our box. We successfully setup and coded a servo so that it can open the lid of the box when the potentiometer is turned. The potentiometer allows the box lid to be raised different heights, but we will replace the potentiometer with code in our final model so that the only input is the switch.
This is the code we used:
int potpin = 0;
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 100);
This is the setup we used:
This is a YouTube video of it working: