Uno R3 No Signal on LED for PWM

Hi, I'm trying to get PWM working with a LED and resistor.

Code below, there's no signal on any of my outputs, I've tried D3 and D10 both PWM support, can someone pl tell me what's missed out here?

package main

import (
	"time"
	"machine"
)

var pwm machine.PWM
var ch uint8

func main() {
	var err error
	pwm.Configure(machine.PWMConfig{})
	ch, err = pwm.Channel(machine.D10)
	if err != nil {
		panic(err)
	}
	pwm.Set(ch, pwm.Top()/2)
	for {
		for i:=1; i<255; i++ {
			pwm.Set(ch, pwm.Top()/ uint32(i))
			time.Sleep(time.Millisecond * 10)
		}
	}
}

The code that you posted is not the usual Arduino code (which is written in C++).

Which board are you using?

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

This looks like Python. Are you trying to use Circuitpython? If so, then I would suggest you go to https://circuitpython.org/ and check out their forum.

it's tinygo :slight_smile:

Hi, @spacewalk
Welcome to the forum.

What is that?
Can you please post a link?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

:frowning: have simplified my code to the below but still there's no signal on DO10. :frowning:

package main

import (
	"time"
	"machine"
)

var pwm machine.PWM

func main() {
	pwm.Configure(machine.PWMConfig{})
	pwm.Set(10, pwm.Top()/2)
	for {
		for i:=1; i<255; i++ {
			pwm.Set(10, pwm.Top()/ uint32(i))
			time.Sleep(time.Millisecond * 100)
		}
	}
}

I suggest you look on the tinygo website (tinygo.org) for help with that code. The Arduino IDE is based on C++, which is very different. You are not going to be able to use the Arduino IDE to compile the code you posted.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.