Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started