#define PIN_LED (1 << PC7)
void setup() {
// put your setup code here, to run once:
DDRF = 0xFF; PORTF = 0;
DDRE = 0xFF; PORTE = 0;
DDRD = 0xFF; PORTD = 0;
DDRC = 0xFF; PORTC = 0;
DDRB = 0xFF; PORTB = 0;
}
void loop() {
// put your main code here, to run repeatedly:
PORTC |= PIN_LED; //led high {setup start}
delay(3000);
PORTC &= ~PIN_LED; //led low {setup end}
//PF0 a5
PORTE |= 1<<PE6;
digitalWrite(13, PINE & (1<<PE6) ); //issue here. if I change to PORTE will work
delay(3000);
PORTC &= ~PIN_LED; //led low {setup end}
PORTE &= ~(1<<PE6);
}
hi
why PINE doesnt read register ?
board leonardo
Which Arduino Leonardo do you have ?
Which version of the Arduino IDE do you use ?
Did you select the "Arduino Leonardo" board ?
Have you installed other boards from Adafruit or Sparkfun that could conflict with the Arduino Leonardo board ?
What does the compiler say ? Please enable extra compiler output in the settings and show us the compiler output.
If you have done everything right, then you need to remove the Arduino IDE, delete the hidden "arduino15" folder and do a fresh install of the Arduino IDE.
like this https://www.arduino.cc/en/uploads/Main/ArduinoMicro_Pinout3.png
ide 1.6.9
yes select. because comment //issue here. if I change to PORTE will work
only this board I have.
warnings all. avrdude done thank you. no warnings
what the hidden folder ?
just verifyed all PIN ports
actually all PINx doesnt read value
all PORTx it does well
actually all PINx doesnt read value
PINE does indeed read the register.
You are misusing the bitwise AND operator (&). Instead, use parentheses as follows:
digitalWrite(13, PINE & (1<<PE6) );
Note that the operation PINE & (1<<PE6) returns a value of either 64 or 0, depending on the PE6 pin state.
thank you
but I tried and with parentheses yesterday, the same result. PINx doesnt read. PORTX doest it
PORTF |= 1<<PF0;
digitalWrite(13, PINF & (1<<PF0) );
and PORTE also return value 64 or 0 and its working well
but I tried yesterday and >>6 the same result PINx doesnt work
PINx does read port register x, guaranteed.
Why do you insist on doing something as stupid as this:
digitalWrite(13, PINF & (1<<PF0) );
when you could do this?
Serial.println(PINF);
This program works EXACTLY AS EXPECTED for me:
void setup() {
Serial.begin(9600);
while (!Serial); //needed for ATmega32u4
Serial.print("DDRF ");
Serial.println(DDRF);
Serial.print("PINF ");
Serial.println(PINF);
PORTF=1; //turn on input pullup
Serial.print("DDRF ");
Serial.println(DDRF);
Serial.print("PINF ");
Serial.println(PINF);
PORTF=0;
DDRF=1; //make output
Serial.print("DDRF ");
Serial.println(DDRF);
Serial.print("PINF ");
Serial.println(PINF);
PORTF=1;
Serial.print("PINF ");
Serial.println(PINF);
}
void loop() {}
Output on serial monitor:
DDRF 0
PINF 0
DDRF 0
PINF 1
DDRF 1
PINF 0
PINF 1
Ok I will try serial printing...
yesterday i tried
If (PINE) ++a;
Doesn't work
Of course that works.
Consider switching to a less challenging hobby.
of course but not of course
this is all ! code with empty board
DDRB = 0xFF; PORTB = 0;
DDRC = 0xFF; PORTC = 0;
DDRD = 0xFF; PORTD = 0;
Serial.println("DDR B C D =");
Serial.println(PINB);
Serial.println(PINC);
Serial.println(PIND);
Serial.println(PORTB);
Serial.println(PORTC);
Serial.println(PORTD);
PORTD = 0x00;
Serial.println(PIND);
Serial.println(PORTD);
output
DDR B C D =
0
0
45
0
0
32
45
32
I have no idea what you are doing, but when I run your code on an "empty" Arduino Uno I get this output as expected. The 1 in PD0 relates to serial.
DDR B C D =
0
0
1
0
0
0
1
0
void setup() {
Serial.begin(115200);
DDRB = 0xFF; PORTB = 0;
DDRC = 0xFF; PORTC = 0;
DDRD = 0xFF; PORTD = 0;
Serial.println("DDR B C D =");
Serial.println(PINB);
Serial.println(PINC);
Serial.println(PIND);
Serial.println(PORTB);
Serial.println(PORTC);
Serial.println(PORTD);
PORTD = 0x00;
Serial.println(PIND);
Serial.println(PORTD);
}
void loop() {
// put your main code here, to run repeatedly:
}
I have no idea what you are doing
I suspect a troll. Waste of time, anyway.
jremington, so if someone need help and he try find out here fix/help/advise , is he troll?
om my god, I found
PORTC |= CLED; //led high {setup start}
delay(3000);
PORTC &= ~CLED; //led low {setup end}
//PF0 a5
//PD6 12
//PE6 7
PORTF |= FLED; //fled 1. portf !=0
delay(3);
//Serial.println(PINF);
//Serial.println(PORTF);
if (PINF) PORTC |= CLED; // if != 0 (true) cled 1. но оно тут не работает
delay(3000);
PORTC &= ~CLED; //led low {setup end}
PORTF &= ~FLED;
if delay less the 3 ms IF will not work... mda... AVR so slowly