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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
60 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 &...
AJ_Smoothie's user avatar
3 votes
1 answer
88 views

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 ...
BRUCE DURANT's user avatar
2 votes
0 answers
170 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 ...
Damiano Miazzi's user avatar
1 vote
2 answers
63 views

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 << ...
fmarquet's user avatar
1 vote
1 answer
74 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(...
Gaai's user avatar
  • 55
1 vote
1 answer
79 views

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 ...
daniel's user avatar
  • 185
3 votes
1 answer
2k 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, ...
gurkensaas's user avatar
-1 votes
2 answers
50 views

5-bit communication method?

OK, I'm working on a project where I want to have multiple toggle switches create a "code" to determine further actions. This is essentially 5-bit communication process that will create ...
Mulcch's user avatar
  • 19
2 votes
2 answers
622 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 ...
Subha Jeet Sikdar's user avatar
1 vote
1 answer
136 views

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 ...
Zhelyazko Grudov's user avatar
0 votes
1 answer
247 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 ...
Pararera's user avatar
  • 213
3 votes
2 answers
403 views

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 =...
Антон's user avatar
1 vote
1 answer
559 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 ...
micahwittman's user avatar
1 vote
2 answers
3k views

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++) { ...
Kekers_Dev's user avatar
1 vote
2 answers
406 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 ...
Santiago Restrepo Serna's user avatar
1 vote
1 answer
293 views

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: ...
floppy380's user avatar
  • 245
-1 votes
1 answer
66 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 ...
pfra's user avatar
  • 1
1 vote
1 answer
3k views

USing arrays, binary data and bitRead

This is my first manually typed code. I'm sure there may be some glaring "schoolboy errors" in it, so wondered if people could give it the 'once over' In particular, I have never used C++ arrays, ...
Cristofayre's user avatar
1 vote
1 answer
391 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 ...
xetra11's user avatar
  • 167
0 votes
1 answer
244 views

MXCHIP IoT DevKit too many initializers for 'unsigned char [0]

Question Trying to call the Display draw API using the sample code for the azure logo bitmap sample code. I'm unable to reach a point where I can the API because breaks when constructing the bitmap ...
greg's user avatar
  • 103
0 votes
2 answers
519 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 = ...
Noel's user avatar
  • 135
3 votes
2 answers
284 views

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 ...
Coyttl's user avatar
  • 133
1 vote
4 answers
7k 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]);...
AlfroJang80's user avatar
-1 votes
1 answer
1k views

transmit a sequence of bit using arduino uno [closed]

How do i code to transmit a sequence of bit using arduino uno?My project is about a transmitter and a receiver.Arduino as the transmitter and an application as the receiver.Light sensor will detect ...
Nyssa's user avatar
  • 15
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] = {...
Katie's user avatar
  • 43
2 votes
3 answers
659 views

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's user avatar
  • 121
0 votes
1 answer
677 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. ...
R R.'s user avatar
  • 1
1 vote
2 answers
553 views

Encode & decode boolean values into a single integer?

I'm trying to record the state of some pins over time. To save memory, I'm thinking about encoding the pin states into a single integer, like this: Pin 1: TRUE Pin 2: FALSE Pin 3: FALSE Pin 4: TRUE ...
Esshahn's user avatar
  • 217
1 vote
2 answers
277 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 ...
Petio Petrov's user avatar
0 votes
2 answers
124 views

Overflow in bit calculation [closed]

I'm having a double buffer to write data from sensors to SD card. inBuf points to the buffer that are written into (from sensors). The other buffer write data to SD card. char buffer[2][BUFLEN]; ...
Dzung Nguyen's user avatar