The Shop > Electronics & IC Programing
Arduino help
John Rudd:
--- Quote from: RodW on June 03, 2013, 04:42:33 PM ---Great news even if I had to were wire a post I was half way through!
--- End quote ---
were wire? :scratch:
Anyhow, thanks for your support and advice...
As Arnie says...'I'll be back' :D
RodW:
--- Quote from: John Rudd on June 03, 2013, 05:15:00 PM ---
--- Quote from: RodW on June 03, 2013, 04:42:33 PM ---Great news even if I had to were wire a post I was half way through!
--- End quote ---
were wire? :scratch:
Anyhow, thanks for your support and advice...
As Arnie says...'I'll be back' :D
--- End quote ---
oops dyslexic fingers - I reworded my post full of useless advice :coffee:
Swarfing:
John you still not said which lcd sheild you have?
John Rudd:
--- Quote from: Swarfing on June 04, 2013, 02:06:34 PM ---John you still not said which lcd sheild you have?
--- End quote ---
Apologies...This one:
http://www.ebay.co.uk/itm/16x2-LCD-Screen-Keypad-Shield-1602-Blue-Arduino-lcd-Shield-UNO-MEGA-2560-UK-Fast-/290922513330?pt=UK_Sound_Vision_Other&hash=item43bc5543b2#ht_380wt_722
All working well...
Now working on compiling code to make a counter for rewinding my genny rotor :D
RodW:
--- Quote from: John Rudd on June 04, 2013, 03:11:53 PM ---
Now working on compiling code to make a counter for rewinding my genny rotor :D
--- End quote ---
John,
Maybe read up on interrupts so that your main processing loop is interrupted by an ISR (interrupt Service Routine) to increment each pulse of the sensor rather than continuously poll for some action. This will require use of a specific port. Keep a count in a global variable in the ISR and let the loop() print the display.
So the ISR probably only has one line of code:
--- Code: ---global_counter++;
--- End code ---
Then the loop can print the count to the LCD at its leisure. If you print continuously, the display I have flickers so I would set a time delay in milliseconds and only print it when the timer expires by using millis(), maybe every 50 to 200 milliseconds decided after a bit of experimenting.
However maybe an even better way would be to only print to the display if the global counter has changed.
Note this is not a complete example and may not compile without a bit of work on your part.
--- Code: ---
unsigned long global_counter = 0;
unsigned long last_reading = 0;
void counter()
{
global_counter++;
}
setup()
{
// remember to set up LCD;
attachInterrupt(0, counter, RISING);
}
loop(){
if(global_counter != last_reading){
lcd.Print(global_counter);
last_reading = global_counter;
}
}
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version