Questions tagged [bit]
A bit (short for binary digit) is the smallest unit of data in a computer. A bit has a single binary value, either 0 or 1. Although computers usually provide instructions that can test and manipulate bits, they generally are designed to store data and execute instructions in bit multiples called bytes.
30 questions
0
votes
1
answer
82
views
Why is char being "extended" to an int?
I know I'm missing something so simple here, but I can't figure it out.
If I do char letter = 'A'; then letter = letter << 8, letter = 0, as one should expect, since we are shifting the bits &...
2
votes
0
answers
379
views
Modbus RS485 Decode the message received
I'm try to read some value from a soil NPK sensor using RS485 Modbus e Arduino uno.
I menage to sent the request msg and I got the response but now i don't know how to read the response in order to ...
1
vote
1
answer
139
views
Do these bit settings all mean the same?
ADMUX = ADMUX | _BV(REFS); // uncompounded bitwise OR
ADMUX |= _BV(REFS0); // #define _BV(bit) (1 << (bit))
ADMUX |= bit(REFS0); // #define bit(b) (1UL << (b))
bitSet(...
3
votes
1
answer
3k
views
Changing single bit in byte array
So I have a byte-array representing the display attached to my Arduino:
byte theDisplay[8] = {
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000,
...
2
votes
2
answers
1k
views
How to control Shift registers output individually bitwise
so i am working on a project which needs a lots of bit manipulation and shifting out the bits to control the pins of shift registers individually.
So i am using 2 shift registers daisy chained with 16 ...
0
votes
1
answer
476
views
Controlling LEDs with bit bang method
I'm doing a research for RGB LED chips that MCU can control with one pin. I found this LED chip and it seems controlling LEDs is not as I've tought. I understand hardware part, software side is a ...
1
vote
1
answer
732
views
Print 2 numbers stored in 24-bits in decimal format
An implementation function from the nice little Wiegand library YetAnotherArduinoWiegandLibrary prints a hexadecimal representation of a facility # & card # (8-bit facility #, 16-bit card #) — 24 ...
1
vote
2
answers
551
views
need to compare if a byte is less than 80 hex
I am using an infrared sensor called OTI301. In its data sheet it says that in order to obtain object temperature and ambient temperature values I need to extract the binary information from the ...
-1
votes
1
answer
83
views
Control 4 digital outputs with one switch
I want to control 4 digital outputs (d0, d1, d2, d3) with one switch. When the Arduino starts, they should all be in state LOW.
Now, after pressing the button once, d0 should get HIGH. Another push ...
1
vote
1
answer
554
views
Bit Number to Byte Value conversion (AVR Docs)
I have hard time to understand what this doc tells me: https://www.microchip.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_use_bv.html
I has a macro called _BV that
convert a bit number (usually ...
0
votes
2
answers
651
views
Replace digitalWrite with a selective bitwise operation
I have the following code with digitalWrite I aim to write with bitwise operation only.
No portability concerns here whatsoever. (for atmega328p here)
#define DATAOUT 11//MOSI
byte commandbits = ...
1
vote
4
answers
8k
views
Hex/Byte Reversing and Conversion
I'm working on an RFID system using a MFRC522 with this Library : https://github.com/miguelbalboa/rfid
Here's the code I have right now:
int A=(mfrc522.uid.uidByte[0]);
int B=(mfrc522.uid.uidByte[1]);...
1
vote
2
answers
2k
views
C++ Adding Two 16 bit binary numbers together
I am trying to add two 16 digit binary numbers together. Each binary number will have been entered by the user and saved as: int binaryOne[16] and int binaryTwo[16]. Originally,
int binaryOne[16] = {...
0
votes
1
answer
790
views
How does Arduino UNO deal with bit shifting?
Explanatory comment: I'm a beginner. I'm examining the feasibly of bit shifting to the right 6 places to divide up the range of the Arduino ADC (has a range of 0 to 1023) to something much smaller. ...
1
vote
2
answers
335
views
Understanding bitwise operations [duplicate]
I am wondering what the second line of code does:
int16_t GyX;
GyX=Wire.read()<<8|Wire.read();
Also, how can I write the GyX value to EEPROM?
From what I understand, int16_t is a two-bytes ...