Subject:
|
Re: programming help.
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Mon, 2 Nov 1998 02:22:55 GMT
|
Original-From:
|
Darkman <LROSKA@CYBERUSantispam.CA>
|
Viewed:
|
1968 times
|
| |
| |
The "<<" is a shift left operator in C
0E is the actual motor port on the Handy Board.
> At 10:34 AM 10/31/98 , Edmund wrote:
> >
> > hello
> >
> > can someone please tell me what does the following command line mean?
> >
> > bit_set(0x0e, 1 << (4 + motor));
> >
> > i know that 0x0e refers to memory location $0E but how does bit_set
> > work? is it similar to poke? and more importantly, what operation
> > does '1 << (4 + motor)' perform?
> >
> > any help will be appreciated. thanks.
> >
> >
>
> In binary 1 is represented by 0000-0001
>
> 1 << 1 is 0000-0010 aka 2
> 1 << 2 is 0000-0100 aka 4
> 1 << 3 is 0000-1000 aka 8
>
> You get the idea? x << y means slide x to the left y times.
>
> motor is probably a number between 0 and 3. 4+motor is then a number between 4 and 7.
>
> so, to go back to your example the result of 1<<(4+motor) is one of:
>
> 1000-0000
> 0100-0000
> 0010-0000
> 0001-0000
>
> And my guess is that bit_set(address, value) is equivalent to poke(address,
peek(address) | value). I don't have any documentation here, so I don't know
what is stored in 0x0e, but it could be the place where you turn the motors
on and off. And the code you are looking at is turning a motor on without
touching the other motors.
>
>
> -- Eric
>
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|