• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 PMW question

Q&A Forum › ESP32 PMW question
0 Vote Up Vote Down
Tim Albin asked 3 years ago

from machine import Pin, PWM
from time import sleep
frequency = 5000
led = PWM(Pin(5), frequency)
while True:
for duty_cycle in range(0, 1024):
led.duty(duty_cycle)
sleep(0.005)

there is a syntex error when I attempt to run this.

File “<stdin>”,Line 1, in <module>

File “<string>”,line7

Not sure what this is. Im following the course so that did not help me. Can some one mabe explain what this is so I can correct this and learn something.

Thanks,

Tim

SyntexError:invalid sntex

2 Answers
0 Vote Up Vote Down
Steve Mercer answered 3 years ago

I’m not a Python guy but I would guess that you have either not flashed your ESP32 with MicroPython or you haven’t installed the IDE correctly. I do know that Python relies on indentation so am assuming that’s correct in your code and it didn’t display correctly here on the forum.

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Tim.
Does that error happen before or after running the program?
What’s the IDE you’re using?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.