Question: can you please help me understand this code better , I have some problems according left shft and right shift operands when it comes to
can you please help me understand this code better , I have some problems according left shft and right shift operands when it comes to setting bits
I have understood that const byte pin11 = 0x1 << PBit; // bit 3 means to set bit 3 to 1 but what is v = (PINB & pin11) >> PBit; // sense voltage at pin 11?
can you let me know how to understand setting bits.
#define PBit 3
const byte pin11 = 0x1 << PBit; // bit 3
void setup() { DDRB &= ~pin11; // config pin 11 as digital input PORTB &= ~pin11; // disable pull-up Serial.begin(9600); // open serial port to host }
void loop() { int v; v = (PINB & pin11) >> PBit; // sense voltage at pin 11
}
Serial.println(v); delay(100);
// send voltage to host // wait 100ms
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
