Timer issue.

Moderators: rtenklooster, BertB, Voyager, Stuntteam

Post Reply
Message
Author
mg64775@gmail.com
Normal user
Posts: 3
Joined: 22 Jan 2020, 19:30
Location: florida us

Timer issue.

#1 Post by mg64775@gmail.com » 31 Jan 2020, 01:34

What is wrong with this code... All I want is to flip the status of a led regularly like every second.
on system#boot do
timerset,1,1
let,1,1
enddo

on rules#timer=1 do
if %v1% = 1
oled,1,1,"ha"
gpio,0,0
let,1,2
timerset,1,1
else
oled,1,1,"hi"
gpio,0,1
let,1,1
timerset,1,1
endif
enddo

TD-er
Core team member
Posts: 2121
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Timer issue.

#2 Post by TD-er » 03 Feb 2020, 14:49

You can add some statement to show a logentry, which may help in debugging. (you already have the oled command, but what if that will update every 2 seconds...)
For example what if the rules are fine, but the LED is not toggling well for whatever reason (e.g. voltage too low or too strong pull up resistor)

You are toggling the value of the variable 1 between 1 and 2.
Just to be sure there is nothing wrong with the if check, can you remove the spaces around the "=", or try replacing it with a "<2" instead of "=1"

TD-er
Core team member
Posts: 2121
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Timer issue.

#3 Post by TD-er » 03 Feb 2020, 14:54

Ah I noticed this is a duplicate question: viewtopic.php?f=5&t=7399

Please don't ask the same thing in different topics if you don't get an answer immediately.

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests