'Bambino-05 SERTXD("B05",CR) 'report program number @4800baud #PicAxe 20M2 #no_data 'Bambino-01 Test eyeLEDs, whiskerLEDs and speaker 'Bambino-02 Test PWM of eyeLEDs 'Bambino-03 Test InfraRed input 'Bambino-04 Test Eye light values 'Bambino-05 Test Whisker light values '----------------------------------------------------------------- Rationale: 'Test Whisker light values '------------------------- 'open the Terminal window [F8] to see the values; ' set the baud to 4800; 'read the analog light values using READADC 'edit holedetect values so Bambino can see table edges 'detected values should 'be greater than the holedetect values when not at an edge 'and lower when at an edge. 'The sensors are affected by the 100Hz (or 120Hz) flicker of artificial light '100Hz is a period of 10ms. 'If we take 6 readings over 10ms intervals then one of them 'will be taken at about a peak in the 100Hz flicker.(if any). 'That way the comparison of the sensor readings with and without 'the LED on will be less affected by the light flicker. 'The 6 readings take 10ms. 'The sensors will have difficulty in bright light, we use sunglasses! '================================================================= SYMBOL VoiceLedpin_ =c.5 SYMBOL eyeLedLpin_ =c.2 'low =>LED on SYMBOL eyeLedRpin_ =b.1 'low =>LED on SYMBOL GwhiskerLedLpin_ =c.3 'low =>Ground whisker LED on SYMBOL GwhiskerLedRpin_ =b.3 'low =>Ground whisker LED on SYMBOL IRinpin =c.6 SYMBOL IRoutpin =b.2 SYMBOL eyeRpin =c.7 SYMBOL eyeLpin =c.1 SYMBOL GwhiskerLpin =b.5 'Ground whisker (down) Left SYMBOL GwhiskerRpin =b.0 'Ground whisker (down) Right 'edit holedetect values so Bambino can see table edges 'detected values should 'be greater than the holedetect values when not at an edge 'and lower when at an edge SYMBOL holedetectL =10 '% light level difference for hole SYMBOL holedetectR =10 '% light level difference for hole 'whisker LEDs on, 82R 1.414v =>17.2mA @4.02V 'B0 counter 'B1 dark sensorval 'B2 light sensorval 'B3 sensorval, light-dark sensor difference 'B4 possible change initialise: HIGH GwhiskerLedLpin_ 'make output, Ground whisker LED Left off HIGH GwhiskerLedRpin_ 'make output, Ground whisker LED Right off start: ReadGwhiskerL: 'more than 10% change of eyeval with LED on => ground seen B2 =0 LOW GwhiskerLedLpin_ 'LED on FOR B0 = 1 TO 6 'the FOR NEXT loop takes 10ms READADC b.5,B3 'sensorval in B3 B2 =B2 MIN B3 'keep the maximum NEXT B0 B1 =0 HIGH GwhiskerLedLpin_ 'LED off FOR B0 = 1 TO 6 'the FOR NEXT loop takes 10ms READADC b.5,B3 'sensorval in B3 B1 =B1 MIN B3 'keep the maximum NEXT B0 B4 =255 -B1 'possible change B3 =B2 -B1 *100 /B4 'scale for % of possible change SERTXD ("L dark=",#B1," light=",#B2," %=",#B3) 'send value back to PC IF B3 ground seen B2 =0 LOW GwhiskerLedRpin_ 'LED on FOR B0 = 1 TO 6 'the FOR NEXT loop takes 10ms READADC b.0,B3 'sensorval in B3 B2 =B2 MIN B3 'keep the maximum NEXT B0 B1 =0 HIGH GwhiskerLedRpin_ 'LED off FOR B0 = 1 TO 6 'the FOR NEXT loop takes 10ms READADC b.0,B3 'sensorval in B3 B1 =B1 MIN B3 'keep the maximum NEXT B0 B4 =255 -B1 'possible change B3 =B2 -B1 *100 /B4 'scale for % of possible change SERTXD ("R dark=",#B1," light=",#B2," %=",#B3) 'send value back to PC IF B3