Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

MU-EDITOR NOT SHOWING SERIAL OF LIGHT SENSOR
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MU-EDITOR NOT SHOWING SERIAL OF LIGHT SENSOR

by wr3484 on Wed Aug 12, 2020 12:28 am

Hi,

I have a circuit playground express, and I am trying to run a very simple photo-light sensor check using Mu.
This is the code:

Code: Select all | TOGGLE FULL SIZE
from adafruit_circuitplayground.express import cpx

while True:
  print(cpx.light)



It is saved as a .py file on the circuitpy drive, every time I load the file in Mu and attempt to run a serial command I get one of the two screens:

[img]
pic1.png
pic1.png (48.51 KiB) Viewed 33 times
[img]

[/img]
pic2.png
pic2.png (38.71 KiB) Viewed 33 times
[/img]

It is not showing any of that data that it should, I don't know if perhaps the sensors are faulty?
Any help would be appreciated.

wr3484
 
Posts: 2
Joined: Wed Aug 12, 2020 12:16 am

Re: MU-EDITOR NOT SHOWING SERIAL OF LIGHT SENSOR

by dastels on Wed Aug 12, 2020 9:00 am

You need to save the file as code.py or main.py in order for it to be loaded and executed.

Dave

dastels
 
Posts: 3505
Joined: Tue Oct 20, 2015 3:22 pm

Re: MU-EDITOR NOT SHOWING SERIAL OF LIGHT SENSOR

by wr3484 on Wed Aug 12, 2020 11:22 pm

That did the trick, thank you. Why does the file need to be named code.py specifically?

wr3484
 
Posts: 2
Joined: Wed Aug 12, 2020 12:16 am

Re: MU-EDITOR NOT SHOWING SERIAL OF LIGHT SENSOR

by dastels on Thu Aug 13, 2020 9:05 am

When CircuitPython starts up it loads either code.py or main.py (I forget which order it looks for them in). It has to know where the main code file is. You can have many python files in CIRCUITPY if you have a large program broken up logically. It has to start somewhere and this is the convention the designers chose.

Dave

dastels
 
Posts: 3505
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.