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.

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
3
votes
1 answer

changing a single bit in an arduino EEPROM byte

In my code I have a number of boolean flags that tell me if data has been written to specific places in the EEPROM. I need to save these flags to the EEPROM and recover them on a restart. Is the following syntax valid to update a single bit in an…
3
votes
1 answer

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, B00000000 }; Now I want to flip a single bit…
gurkensaas
  • 163
  • 1
  • 6
3
votes
2 answers

Form a signal from an array of bits

I need to reproduce with a digital pin of an Arduino such a key in the form of a sequence of 1's and 0's, where a one takes 2 ms high and 2 ms low, and a zero takes 1 ms high and 1 ms low. int key = 0b101100001111; void setup() { pinMode(13,…
Антон
  • 265
  • 3
  • 10
3
votes
2 answers

Testing Conditions on Port Bytes - ignoring certain bits?

Being new to testing byte and bit conditions, I feel like there has to be a better way to test for conditions/values on a byte (read from a port). For example, I'm reading 8 bits from PORTK. I need to test for a pattern of high bits. (Say, byte…
Coyttl
  • 133
  • 4
2
votes
0 answers

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 get the information I need. the following code sent…
Damiano Miazzi
  • 151
  • 1
  • 6
2
votes
2 answers

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 LEDS. Now, what i want is that, i want to…
2
votes
3 answers

Arduino status of bit

Is the a way to check the status of a bit in an arduino Uno? Like how in Atmel AVR, there is bit_is_clear or bit_is_set
JoeyB
  • 119
  • 3
1
vote
2 answers

Bitwise Operator in Arduino Code Question

What is the below Arduino code doing? I am not familiar with the '+' with regard to bitwise operations. Just getting familiar with this stuff. return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) &…
fmarquet
  • 33
  • 5
1
vote
1 answer

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(ADMUX, REFS0); // #define bitSet(value, bit) ((value) |=…
Gaai
  • 55
  • 6
1
vote
1 answer

Why is there a cutoff on these accelerometer measurement values? - ADXL375

I'm using a Teensy 3.2 to read data from an ADXL375 using SPI. In general the communication is going just fine and I can activate settings etc. However, when I try to read X, Y or Z data it seems like some part of the measurement values are…
daniel
  • 185
  • 6
1
vote
1 answer

Writing to partially reserved registers of sensors

I'm trying to change the range of a gyroscope I'm using and there is the following guideline: it is recommended to mask out (logical and with zero) reserved bits of registers which are partially marked as reserved. I tried reading about bit…
Zhelyazko Grudov
  • 367
  • 2
  • 15
1
vote
1 answer

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 bits of a 26-bit stream that comes across the…
micahwittman
  • 113
  • 4
1
vote
2 answers

LSB/MSB and shiftOut

Here is the shiftOut function code from wiring_shift.c void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) { uint8_t i; for (i = 0; i < 8; i++) { if (bitOrder == LSBFIRST) …
Kekers_Dev
  • 13
  • 1
  • 4
1
vote
2 answers

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 sensor and use the binary information in given…
1
vote
1 answer

How to split a binary data to form two split binary data?

I want to split a received binary data into two binary data. Take the following received binary data for instance: uint32_t data = 0xFFFF0001; In binary format it is: 11111111111111110000000000000001 If we need to split this above binary into two…
floppy380
  • 245
  • 1
  • 4
  • 10
1
2