Hello!
I have been working on a sketch which uses a 16x2 LCD to display the distance an object is from an ultrasonic sensor, and LEDs lighting up at certain distances. I want to condense the code for practice with binary and to make the sketch a little shorter. I haven't used binary before, and I want to know how I should mark the LCD pins, or just make the sensor's trig/echo pins and leds as inputs and outputs without affecting the LCD's pins.
Ultrasound_LCD.ino (2.15 KB)
. . . I want to condense the code for practice with binary . . .
. . . I haven't used binary before . . .
Perhaps you should explain what you mean by 'binary' in this context.
The best I can come up with is that you may possibly be referring to 'Port Manipulation'.
Don
Using this to condense it
DDRD = DDRD | B11111100;
Ok - I got that part right.
You might get some ideas from some of the LCD Programming Examples at Don's Collected Technical Information.
Specifically, compare one of the 'Arduino' examples with it's corresponding 'C' example. You can use the comments, which are essentially identical for both programs (except for at least one typo I just spotted), to see how the Arduino bit manipulation techniques compare to the more traditional approach.
Don