Introduction: How to Calculate Angles on a Pic32 Using Arduino IDE
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.
place this into loop() function. If the value of the Analog Potentiometer's value is zero, set all LED pins to low
If the value between 1-255 which corresponds to angle 1-45 degree, set LED 1 pin to high and the rest to low.
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.
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.
If the value 766-1020 which corresponds to angle 136-180 degree, set all LED pins to high.
We have a be nice policy.
Please be positive and constructive.