code. Seems the old 4011 in the NES controller isn't that fast
afterall!
// Data to store the pins for each controller
struct nesPinsStruct
// Data to store the pins for each controller
struct nesPinsStruct
// Toggle Latch - which presents the first bit
// Toggle Latch - which presents the first bit
- digitalWrite (pins->lPin, HIGH) ;
- delayMicroseconds (1) ;
- digitalWrite (pins->lPin, LOW) ;
- delayMicroseconds (1) ;
+ digitalWrite (pins->lPin, HIGH) ; delayMicroseconds (PULSE_TIME) ;
+ digitalWrite (pins->lPin, LOW) ; delayMicroseconds (PULSE_TIME) ;
for (i = 0 ; i < 7 ; ++i)
{
for (i = 0 ; i < 7 ; ++i)
{
- digitalWrite (pins->cPin, HIGH) ;
- delayMicroseconds (1) ;
- digitalWrite (pins->cPin, LOW) ;
- delayMicroseconds (1) ;
+ digitalWrite (pins->cPin, HIGH) ; delayMicroseconds (PULSE_TIME) ;
+ digitalWrite (pins->cPin, LOW) ; delayMicroseconds (PULSE_TIME) ;
value = (value << 1) | digitalRead (pins->dPin) ;
}
value = (value << 1) | digitalRead (pins->dPin) ;
}