Hi,
I've seen many youtube videos about ir car controls...
In most videos, it looks quite frustrating. The cars, although always respond to forward / backward or left / right commands, but you can not precise control the vehicles.
I wanted to do that with my MSP430 Launchpad an a Syma 107 R Helicopter remote, but the appropriate library ist not yet available.
I can not do anything with PIND and _BV. Even google could not help me. (still newbie
)
(the problem seems to be due to the masking and the left shift)
#include <SymaLib.h>
#define IRpin_PIN PIND
#define IRpin 2
int listenForIR(void) {
currentpulse = 0;
while (1) {
uint16_t highpulse, lowpulse;
highpulse = lowpulse = 0;
while (IRpin_PIN & _BV(IRpin)) {
highpulse++;
delayMicroseconds(RESOLUTION);
if (((highpulse >= MAXPULSE) && (currentpulse != 0))|| currentpulse == NUMPULSES) {
return currentpulse;
}
}
pulses[currentpulse][0] = highpulse;
while (! (IRpin_PIN & _BV(IRpin))) {
lowpulse++;
delayMicroseconds(RESOLUTION);
if (((lowpulse >= MAXPULSE) && (currentpulse != 0))|| currentpulse == NUMPULSES) {
return currentpulse;
}
}
pulses[currentpulse][1] = lowpulse;
currentpulse++;
}
}
Can someone help me with the conversion?
I get the messages:
sketch_mar24a.ino: In function 'int listenForIR()': sketch_mar24a.ino:69:12: error: 'PIND' was not declared in this scope sketch_mar24a.ino:69:33: error: '_BV' was not declared in this scope sketch_mar24a.ino:81:15: error: 'PIND' was not declared in this scope sketch_mar24a.ino:81:36: error: '_BV' was not declared in this scope
Original Arduino lib:
http://www.jimhung.co.uk/?p=1138
