Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Beginners blinking led code
Author | Message | ||||
FrankMc Newbie Joined: 09/08/2011 Location: AustraliaPosts: 16 |
Hi Guys Apologie,s for the newbie questions..But do we have any sample code for say blinking an led... Thanks Frank |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Hi Frank, This code will flash the Power LED is actually on Pin(0) 10 pause 500:pin(0)=0:pause 500:pin(0)=1:pause 500:pin(0)=0:pause 500:pin(0)=1:pause 500:pin(0)=0:pause 500:pin(0)=1 If you want to blink an LED on another I/O pin you will need to set it first as a Digital Output Setpin x,8 (see page 13 of the manual) where x is the pin you wish to use. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
FrankMc Newbie Joined: 09/08/2011 Location: AustraliaPosts: 16 |
Hi Mick I copied and pasted the sample you gave but when i hit enter no flashy led...Do you have to type each command in with line number...?? Thanks Frank |
||||
ajkw Senior Member Joined: 29/06/2011 Location: AustraliaPosts: 290 |
Frank, Did you run the program after pasting in Mick's code?? Another example would be 5 ppin = 1 10 for i = 1 to 20 20 ppin = not (ppin) 'ppin value will alternate a value of 0 or 1 30 pin(0) = ppin 'set the led on or off per value of ppin 40 pause 200 'pause for a time in milliseconds. 50 next i 60 pin(0) = 1 'leave the led on once we are finished Anthony. |
||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
If you have an SD Card Frank, just copy the file as "flash0.bas" to it. Then load "flash0.bas" to the maximite. "list" to make sure it is there. Then "run" https://www.dontronics.com |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
10 setpin 0,8 20 pin(0)=1 30 pause 200 40 pin(0)=0 50 pause 200 60 goto 20 The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Apologie,s for the newbie questions..But do we have any sample code for say blinking an led... Thanks Frank Hi Frank, This code will flash the Power LED is actually on Pin(0) 10 pause 500:pin(0)=0:pause 500:pin(0)=1:pause 500:pin(0)=0:pause 500:pin(0)=1:pause 500:pin(0)=0:pause 500:pin(0)=1 If you want to blink an LED on another I/O pin you will need to set it first as a Digital Output Setpin x,8 (see page 13 of the manual) where x is the pin you wish to use. Regards, Mick Hi Mick I copied and pasted the sample you gave but when i hit enter no flashy led...Do you have to type each command in with line number...?? Thanks Frank The line number (10) is there.. When you cut and pasted it should have loaded the program into the Maximite To start the program type RUN Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
FrankMc Newbie Joined: 09/08/2011 Location: AustraliaPosts: 16 |
Apologie,s for the newbie questions..But do we have any sample code for say blinking an led... Thanks Frank Hi Frank, This code will flash the Power LED is actually on Pin(0) 10 pause 500:pin(0)=0:pause 500:pin(0)=1:pause 500:pin(0)=0:pause 500:pin(0)=1:pause 500:pin(0)=0:pause 500:pin(0)=1 If you want to blink an LED on another I/O pin you will need to set it first as a Digital Output Setpin x,8 (see page 13 of the manual) where x is the pin you wish to use. Regards, Mick Hi Mick I copied and pasted the sample you gave but when i hit enter no flashy led...Do you have to type each command in with line number...?? Thanks Frank The line number (10) is there.. When you cut and pasted it should have loaded the program into the Maximite To start the program type RUN Regards, Mick Thanks Mick That did the trick....Looks like i have lots of reading to do... Frank |
||||
FrankMc Newbie Joined: 09/08/2011 Location: AustraliaPosts: 16 |
Thanks for the replys guys im going to build Rohans boards and then try and get some i/o working...I have the Maximite manual prined out so i,ll read some but im sure i,ll have more dumb questions soon.. Frank |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Thanks Mick That did the trick....Looks like i have lots of reading to do... Frank No worries, We all start somewhere... Now the fun begins.. regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
Reminds me of when I wrote my first "HELLO WORLD" program in March 1978 on my TRS-80 Model-I. Don't do what I did. Spend 8 hours writing a program, then have your wife switch your computer off, so she can plug in a double adapter to do the ironing, and you haven't done a back up. Cheers Don... https://www.dontronics.com |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Reminds me of when I wrote my first "HELLO WORLD" program in March 1978 on my TRS-80 Model-I. Don't do what I did. Spend 8 hours writing a program, then have your wife switch your computer off, so she can plug in a double adapter to do the ironing, and you haven't done a back up. Cheers Don... I bet it was the BEST program ever written in the history of the world too? Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
aargee Senior Member Joined: 21/08/2008 Location: AustraliaPosts: 255 |
Gees, Don, it took you eight hours to write a "Hello World" program? - Rob For crying out loud, all I wanted to do was flash this blasted LED. |
||||
donmck Guru Joined: 09/06/2011 Location: AustraliaPosts: 1313 |
- Rob Yes, and flashing LEDs took 16 hours, so these newbies "ain't seen nothing yet". I didn't realize that some newbies had no programming experience whatsoever, so the flashing LED type programs, are a very good step in the right direction. If we are to introduce Maximites to kids and schools, we need some basic tutorials, to get them started. I am prepared to host something on my blog, but writing them is another thing, as I am always pushed for time. If no one else wants to do something, I may attempt something simplistic to at least get it started. Cheers Don... https://www.dontronics.com |
||||
Dinosaur Guru Joined: 12/08/2011 Location: AustraliaPosts: 311 |
Hi all I would start by pointing them to here http://www.o-bizz.de/qbtuts/gw-train/index.htm Then it only needs a small article about the oddities of the MmBasic. Regards Regards Hervey Bay Qld. |
||||
Worm Newbie Joined: 30/06/2011 Location: New ZealandPosts: 38 |
Don, Im sure that would be an appreciated by a lot of newbies including myself. Progaming can be very difficult and frustating to learn without help and also very rewarding when something works. Tutorials with some code would be very helpfull including some simple things that we take for granted like always start with the "NEW" command so we dont end up with a mixed up program from previous tries that may stop it from working. Thanks Kevin There's no such thing as a free lunch. |
||||
Print this page |