circuit_projects

Circuit Projects

Blogger

EEWeb Stats

Circuit's Blog :

Return to Blog

Using C Pointers in Arduino Code

The project is a combination of servo, ultrasonic range sensor and an Arduino to create pointers in C in order to move data around.

Figure:1

Figure 1 

The system was built with one piece at a time starting with the PING sensor. The distance of the hand from the sensor can be read by the serial monitor when the hand is put in front of the sensor. Based on how far the PING is from an object, the LEDs are made to dim and brighten. As the variable inches gets smaller, a LED is placed on a PWM pin that is dimming. The servo is made to move through its range using the servo knob example which uses an analog input, instead of using the servo library.

The use of pointers came on the issue of making the PING sensor talk to the servo. The refresh rate on the servo and the PING sensor made it necessary for these to be set up as separate functions which ended up needing a timer to call them at timed intervals so that the refresh rates do not make the servo jittery. The use of pointers illustrates how to point to a memory address of a variable as opposed to a variable.

A program was made to make the servo move closer to the sensor until the servo is almost at the sensor and then move it away as soon as it gets an inch or so away.

Rest of the Project

Comments on this post:

There are currently no comments.

Login or Register to post comments.
 
Click Here