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
1 vote
1 answer
56 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(...
  • 15
-2 votes
0 answers
23 views

Number of cycles for ADC conversion

How do we calculate the number of cycles needed for X-bit ADC conversion? For example, why 10-bit ADC takes 13 ADC cycles? 10 cycles are needed for the core information. What are the other 3 used for? ...
1 vote
1 answer
52 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 ...
  • 63
1 vote
1 answer
642 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, ...
-1 votes
2 answers
48 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 ...
  • 19
2 votes
2 answers
173 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 ...
1 vote
1 answer
71 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 ...
0 votes
1 answer
128 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 ...
  • 213
3 votes
2 answers
287 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 =...
1 vote
1 answer
406 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
2k 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++) { ...
1 vote
2 answers
347 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 vote
1 answer
176 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: ...
  • 225
-1 votes
1 answer
51 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
1 vote
1 answer
2k 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, ...
1 vote
1 answer
299 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 ...
  • 167
0 votes
1 answer
190 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 ...
  • 103
0 votes
2 answers
409 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 = ...
  • 117
3 votes
2 answers
261 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 ...
  • 133
1 vote
4 answers
6k 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 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 ...
  • 15
0 votes
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] = {...
  • 33
2 votes
3 answers
422 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
  • 121
0 votes
1 answer
571 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
1 vote
2 answers
467 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 ...
  • 117
1 vote
2 answers
227 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 ...
0 votes
2 answers
119 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]; ...