I am making a triac-controlled light dimmer. To control the triac I want to use pins A4 or A5, because others are occupied. I have tried the following functions and methods, but nothing seems to put the pins to HIGH state:
1. pinMode(A4, OUTPUT);
digitalWrite(A4, HIGH);
2. pinMode(18,OUTPUT);
digitalWrite(18,HIGH);
3. DDRC |= (1 << DDC4);
PORTC |= (1 << PC4);
I have tried the same things with A5 and other A# pins to no avail. The only pin that works is A0. Only when the triac is connected to it, the lamp lights on.
Is this a valid way to set analog pins?
void setup(){
pinMode(A4, OUTPUT);
}
void loop(){
digitalWrite(A4, HIGH);
}
- Edit: My code was quite messy, it appears that some other functions prevented from using pins A4 or A5. It is working now.
- It was the DS1307Emulator library. After initialization I had to use
DS1307Emulator.busDisconnect();Didn't know it uses I2C.
