Page 1 of 1

uPyCraft REPL behaviour differs from upload/run

Posted: Fri Dec 18, 2020 7:31 pm
by BikerMark

Hopefully somebody can help me out here. I must be overlooking something...

When I upload and run this file with uPyCraft 1.1 onto my ESP32 Devkit C it runs fine. These lines make an array of LEDs lightning up and extinguishing again flawlesly (nice for next to the Christmas tree:).

Code: Select all

import machine
from machine import Pin, PWM

#define leds/colors on pins:
G = Pin(23, Pin.OUT)
W = Pin(22, Pin.OUT)
Y = Pin(19, Pin.OUT)
B = Pin(18, Pin.OUT)
R = Pin(21, Pin.OUT)
arr = [G,W,Y,B,R]

#Some vars to control what's going on:
count = 0
tot = 100
dure = 0.01
pastI = 10

#a fixed number loop:
for i in range(tot):
  i = randint(0, 4)
  #avoid ligtning same led as previous:
  if i == pastI :
    i = pastI + 1
    if i > 4 :
      i = 1
  #counter to maximize runs
  count +=1
  if count < tot+1:
    #init PWM-object of any of the pins from above:
    pwm0 = PWM(arr[i])
    for a in range(1000):
      #increase intensity
    for u in range(1000):
      #decrease intensity:
    pasteI = i
    #switch off the led:
However, when I take snippets of this code and place them into the REPL, the LEDs won't react at all. Not a single setting of PWM on any LEDpin has any effect.
Eventually I want to use the ADC value of a phototransistor (VISHAY TEPT5700) to set the PWM of one of these LEDs above.

Does anybody have a clue here, please?

Thank you sooo much!

Re: uPyCraft REPL behaviour differs from upload/run

Posted: Sat Dec 19, 2020 6:43 pm
by BikerMark
Oh Oh... Just figured out I was trying to control a Fawlty LED! :oops: