loading

This is an instructable to on how to calculate angle between 0-180 degree using pic32 Analog Potentiometer and LED lights on aduino IDE

1. upload bootloader in pic32 using mplabx (this needs to be re-upload everytime you need to upload your code into the pic32 on arduino IDE) boot loader file is included in the file.

2. set LED pins to ledpin 1-4 and initialize it as output in the setup() function

3. by using analog.read(8) function will give you a value between 0-1023 as output of the Analog Potentiometer. This can act as measurement for your angles.

Step 1:

place this into loop() function. If the value of the Analog Potentiometer's value is zero, set all LED pins to low

Step 2:

If the value between 1-255 which corresponds to angle 1-45 degree, set LED 1 pin to high and the rest to low.

Step 3:

If the value between 256-510 which corresponds to angle 45-90 degree, set LED 1 and LED 2 pins to high and the rest to low.

Step 4:

If the value between 511-765 which corresponds to angle 90-135 degree, set LED 1, LED 2, LED 3 pins to high and the LED 4 pin to low.

Step 5:

If the value 766-1020 which corresponds to angle 136-180 degree, set all LED pins to high.

<p>Neat project! I like how you used only the on-board hardware!</p>
<p>cool pic project</p>

About This Instructable

319views

6favorites

License:

More by justinle819:How to calculate angles on a pic32 using arduino IDE 
Add instructable to: