Lesson 1, Topic 1
In Progress

Code for controlling the servo motors using potentiometer Copy



Steps to do coding in Tinkercad

1. Click the code editor button to open the coding panel.


We will code to rotate the servo motor using potentiometer 

  1. First we will make a variable named as “sensorvalue” and store the value coming from the potentiometer in it i.e via analog pin A0.

  2. Then we will make one more variable named as “output value” and then map value  coming from the   potentiomter in the range 0 to 0 to 180. 

  3.  Now, we will use rotate servo pin block to rotate the servo motor as per the change in resistance of potentiometer.

Make the code as shown below: