View previous topic :: View next topic |
Author |
Message |
pvdbos
Joined: 25 Nov 2006 Posts: 96 Location: Edam
|
Posted: Thu Oct 30, 2014 8:38 pm Post subject: shift leds |
|
|
Hello all,
is it possible to shift 4 leds to left or right?
I do now with this code:
Rood Alias Portc.7 'LED
Blauw Alias Portc.6 'LED
Groen Alias Portc.5 'LED
Oranje Alias Portc.4 'LED
Config Portc.4 = Output 'Blauwe LED
Config Portc.5 = Output 'Rode LED
Config Portc.6 = Output 'Groene LED
Config Portc.7 = Output 'Oranje LED
Sub Leds
For X = 1 To 6
Toggle Groen
Waitms 125
Toggle Groen
Toggle Rood
Waitms 125
Toggle Rood
Toggle Blauw
Waitms 125
Toggle Blauw
Toggle Oranje
Waitms 125
Toggle Oranje
Next
End Sub
but is there an higher code level with shift or something?
(BASCOM-AVR version : 2.0.7.7 ) _________________ http://www.hobbyrobots.nl |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
|
Back to top |
|
|
pvdbos
Joined: 25 Nov 2006 Posts: 96 Location: Edam
|
Posted: Thu Oct 30, 2014 9:13 pm Post subject: |
|
|
Mark
the 4 other ports they are not affected with this code?
they are used for something else. _________________ http://www.hobbyrobots.nl |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Oct 30, 2014 9:17 pm Post subject: |
|
|
do you understand the code?
please have a good look at it. if you do not understand a part let me know. _________________ Mark |
|
Back to top |
|
|
pvdbos
Joined: 25 Nov 2006 Posts: 96 Location: Edam
|
Posted: Thu Oct 30, 2014 9:37 pm Post subject: |
|
|
Yes I understand the code but I think to difficult
when I see an example then it's easy. _________________ http://www.hobbyrobots.nl |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Thu Oct 30, 2014 11:44 pm Post subject: |
|
|
A comment about the general principles here, not about this particular problem:
The aim of programming should be to get a computer to do the repetitive tasks we dont want to do. So we should avoid repetitive programming, let the computer do that !
This is a general problem in many 'high level' programming languages. In particular in languages which use objects, its almost mandatory to name the objects, and then have to treat them individually, by name. The concept of using a simple loop to access each object is almost forgotten.
I see the same in many posts where people have constructed a huge list of commands, or a very large select...case statement, to access a list of operations, where a simple loop through an array with an index would be far more efficient. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
|