Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
69 lines (57 sloc) 1.343 kb
#define SCANNERMOTOR OUT_A
#define SCANNORMOTORDIPANGLE 73
#define SCANNERSENSOR S1
#define SCANNERTHRESHOLD 35
//#define DEBUGSENSOR
#define WRITEMOTOR OUT_B
#define TAPEMOTOR OUT_C
#define TAPEMOTORANGLE ((8*360) + 155)
byte readBit() {
RotateMotor(SCANNERMOTOR, 20, -SCANNORMOTORDIPANGLE);
Wait(200);
SetSensorColorGreen(SCANNERSENSOR);
ResetSensor(SCANNERSENSOR);
unsigned int val = Sensor(SCANNERSENSOR);
#ifdef DEBUGSENSOR
TextOut(15, LCD_LINE2, StrCat("RAW: ", NumToStr(val)));
#endif
SetSensorColorNone(SCANNERSENSOR);
ResetSensor(SCANNERSENSOR);
RotateMotor(SCANNERMOTOR, 30, SCANNORMOTORDIPANGLE);
Wait(10);
return val < SCANNERTHRESHOLD ? 1 : 0;
}
inline void incrementTapePosition() {
RotateMotor(TAPEMOTOR, 80, -TAPEMOTORANGLE);
}
inline void decrementTapePosition() {
RotateMotor(TAPEMOTOR, 80, TAPEMOTORANGLE);
}
inline void write1() {
RotateMotor(WRITEMOTOR, 20, -180);
}
inline void write0() {
RotateMotor(WRITEMOTOR, 20, 180);
}
task main() {
bool forward = true;
while (true) {
for (int bit = 0; bit < 10; bit++) {
if (readBit() == 1) {
TextOut(15, LCD_LINE1, "Bit: 1");
write0();
}
else {
TextOut(15, LCD_LINE1, "Bit: 0");
write1();
}
if (forward) {
incrementTapePosition();
}
else {
decrementTapePosition();
}
}
forward = !forward;
}
}
Jump to Line
Something went wrong with that request. Please try again.