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

Microsoft's MakeCode platform for easy blocks-style programming

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Louderthaneverythingelse
 
Posts: 8
Joined: Tue Sep 15, 2020 4:19 am

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

Post by Louderthaneverythingelse »

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

User avatar
johnpark
 
Posts: 985
Joined: Wed Mar 25, 2009 2:15 pm

Re: Use of buttons to record the signal read by the light se

Post by johnpark »

Have you tried adjusting the buffer size and/or baud rate for the serial output?

User avatar
Louderthaneverythingelse
 
Posts: 8
Joined: Tue Sep 15, 2020 4:19 am

Re: Use of buttons to record the signal read by the light se

Post by Louderthaneverythingelse »

johnpark wrote:Have you tried adjusting the buffer size and/or baud rate for the serial output?
Good idea!
I kindly ask if you are aware of buffering and baud rate values ​​( i'm currently using 115200) ideal for an application like this?

Thanks so much for the advice, I'll try soon!

Locked
Please be positive and constructive with your questions and comments.

Return to “MakeCode”