uPyCraft REPL behaviour differs from upload/run

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
BikerMark
Posts: 2
Joined: Fri Dec 18, 2020 6:59 pm

uPyCraft REPL behaviour differs from upload/run

Post by BikerMark » Fri Dec 18, 2020 7:31 pm

Hi,

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
      pwm0.duty(a)
      time.sleep(dure)
    for u in range(1000):
      #decrease intensity:
      pwm0.duty(1000-u)
      time.sleep(dure)
    pasteI = i
    #switch off the led:
    pwm0.duty(0)
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!

BikerMark
Posts: 2
Joined: Fri Dec 18, 2020 6:59 pm

Re: uPyCraft REPL behaviour differs from upload/run

Post by BikerMark » Sat Dec 19, 2020 6:43 pm

Oh Oh... Just figured out I was trying to control a Fawlty LED! :oops:

Post Reply