0 Members and 1 Guest are viewing this topic.
.org $9D93 .db $BB,$6Dkeys5thCol = $FDkeysArrows = $FE; equates for sending values; R → red → tip, W → white → ring; L → low, H → highwRLWL = 3wRHWL = 2wRLWH = 1wRHWH = 0 ld b,RHWHStart: ld a,$FF out (1),a ld a,b out (0),a ld a,keysArrows out (1),a nop in a,(1) cpl and %00001110; no arrow pressed jr z,setRHWH bit 1,a call nz,setRHWL bit 2,a call nz,setRLWH bit 3,a call nz,setRLWLSkip: ld a,keys5thCol out (1),a nop in a,(1) bit 6,a jr nz,Start ld a,wRHWH out (0),a retsetRLWH: ld b,wRLWH retsetRHWL: ld b,wRHWL retsetRHWH: ld b,wRHWH jr SkipsetRLWL: ld b,wRLWL ret.end
int ring = 2, tip = 4; // let's say that the ring is port 2 and the tip port 4void setup(void){ pinMode(ring, INPUT); pinMode(tip, INPUT); Serial.begin(9600);}int getBit(int port){ if(digitalRead(port) == HIGH) return 0; else return 1;}void loop(void){ Serial.print("Command received : "); switch((getBit(ring) << 1) | getBit(tip)) { case 0: Serial.println("don't move"); break; case 1: Serial.println("rotate right"); break; case 2: Serial.println("rotate left"); break; case 3: Serial.println("go forward"); break; }delay(1000);}