Adafruit is open and shipping! Let's build back better, together!
0

Use of buttons to record the signal read by the light sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Use of buttons to record the signal read by the light sensor

by Louderthaneverythingelse on Fri Nov 20, 2020 2:10 pm

Hello Everybody!
I am trying to use Circuit express playground as a Lab-on-a-chip for biomedical diagnostic tests. To calibrate the reading of the light signal, I gave button A the function of manually lowering the PWM of a led, while button B is used to read the signal by the light sensor.

I am currently viewing the board actions using a TTL as serial. Then I connect through alligator clips the GND of the TTL to the GND of the board and the RX of the TTL to the TX of the board, using Hercules as terminal software for serial ports.

I'm having trouble using the buttons. After about ten readings (using key B) the script stops, preventing any other action (it also blocks the function given to key A). Using a script with the same purpose but with a for loop, I've never encountered any problems.

Am I missing something? Does anyone have any idea why this happens?

Here's the link of the script in case anyone wants to try and see where I went wrong:

https://makecode.com/_CT8eeF85RgsD

Here's also the link of the script with the for loop, which instead gave no problems in the readings from the light sensor:

https://makecode.com/_XsfcPPfAcM9j

Thanks in advance!!

Alessandro

Louderthaneverythingelse
 
Posts: 3
Joined: Tue Sep 15, 2020 4:19 am

Please be positive and constructive with your questions and comments.