I just joined and need help for my first project. I looked at Bit in Reference, but does anyone know of good examples of Bit? I'm hoping I can use it, but I don't understand the functions.
I learn better through example. ![]()
"bit(bitPosition)
Returns the value of the given bit position: bit(0) is 1, bit(1) is 2, bit(2) is 4, and
so on"
It is a macro in Arduino.h
#define bit(b) (1UL << (b))
Look at the shift instruction.
LarryD:
It is a macro in Arduino.h
#define bit(b) (1UL << (b))
Look at the shift instruction.
I don't understand what that part means.
Take 1 and multiply it by 2b
I have two buttons. I want them to start out at 0, then when they are pressed down, they are 1, and if Button A is at 0 and Button B is at 1, an LED turns on. However, I need the 1 and 0 because I want the LED to have a pause before turning on if the values go from both 0 to Button A at 0 and Button B at 1. I have two questions about doing this.
a. Is it possible?
b. Would I use Bit?
If I can't use Bit, but it is possible, can someone tell me how this type of thing would be done?
TechnoFries:
I have two buttons. I want them to start out at 0, then when they are pressed down, they are 1, and if Button A is at 0 and Button B is at 1, an LED turns on. However, I need the 1 and 0 because I want the LED to have a pause before turning on if the values go from both 0 to Button A at 0 and Button B at 1. I have two questions about doing this.a. Is it possible?
b. Would I use Bit?
If I can't use Bit, but it is possible, can someone tell me how this type of thing would be done?
It's a lot easier to implement if you imagine they start off as 1 and then they go to 0 when you close the switch.
No, you don't need to use the bit macro,
What would I use?
Look at "digitalRead(yourButton);"
Look at "if"
Look at "&&"
Take a look at the programming examples built into the IDE
So... How do I make sure if they go from both untouched to button B pressed the LED will pause?
How much experience do you have in programing?
AWOL suggested you go through the examples that are found in the examples of the IDE
They will give you a great footing so you can proceed with your project.
I looked at the first 5 in the USK guide code thingy.
TechnoFries:
I looked at the first 5 in the USK guide code thingy.
Can you explain what that means, please?
We have the Arduino Uno Rev3 Ultimate Starter Kit and the Vilros Ultimate Starter Kit Guide. The Guide goes along with 10 programs in a folder labeled 'USK Guide Code'.
I still don't know what that means.
I understand "looked at", but how many have you worked though and fully understood?
That's what I meant by "looked at". I've given you the deepest explanation I can, maybe you could google it.
So, maybe it's time to progress a bit further and try a few more examples.
Try blink without delay; that seems to sort the sheep from the goats.
Have you done any examples using digitalRead() ?
...Could you please just help me with what I asked in 9? (Not to be rude or anything... I just really want to finish this program before doing anything else.)
Have you "looked at" the blink without delay example?
Did you understand it?