Pots and Leds

So I want to have 2 pots, so they can each control the brightness of an led, for a project. I tried modifying the AnalogInOutSerial code to where it fit my needs, but it wouldn't work.

Can someone send me a working code for 2pots and 2 leds

Also this is for an Attiny85

Arduino_User49502:
Can someone send me a working code for 2pots and 2 leds

You can pay someone to write code for you, or you can post your code and we can help you figure out what the problem is. Nobody here writes code assignments for free.

I apologize, I didn't expect a reply this soon. I was planning on posting the code in a few hours when it is more convenient for me. In reflection I will only post when I'm ready.

int dummy;
void setup(){
pinMode (3, OUTPUT); // Uno PWM output
pinMode (5, OUTPUT); // Uno PWM output
}
void loop(){
dummy = analogRead(0); // dummy read to let pot value settle
analogWrite (3, analogRead(0));
dummy = analogRead(1);// dummy read to let pot value settle
analogWrite (5, analogRead(1));
}

Whew! That was a tough one. Make IO agrees with your hardware.

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
const int analogInPin2 = A1;  // Analog input pin that the potentiometer is attached to
const int analogOutPin2 = 10; // Analog output pin that the LED is attached to
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
int sensorValue2 = 0;        // value read from the pot
int outputValue2 = 0;        // value output to the PWM (analog out)

void setup() {
  Serial.begin(9600); 
}

void loop() {
  sensorValue = analogRead(analogInPin);
  sensorValue2 = analogRead(analogInPin2);            
  outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
  outputValue = map(sensorValue2, 0, 1023, 0, 255);   
  analogWrite(analogOutPin, outputValue); 
  analogWrite(analogOutPin2, outputValue2);          
  delay(2);                     
}

yeah this is the code I tried, can anyone tell me the flaws

outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
  outputValue = map(sensorValue2, 0, 1023, 0, 255);

Which sensorValue should map to which outputValue?

I'm assuming that when you say it didn't work you mean the two leds both reacted to the same pot.

No, I missed typed and I apologize, it told that "const int analogInPin = A0;" was undefined

Please copy and paste the actual error message AND the actual code that actually caused that actual message.

Hmm, these should have been
analogWrite (3, (analogRead(0)>>2)); // convert 10 bit to 8 bit
See how I used pinMode in mine for the outputs? I think you need that.

I ran this code this morning...

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
const int analogInPin2 = A1;  // Analog input pin that the potentiometer is attached to
const int analogOutPin2 = 10; // Analog output pin that the LED is attached to
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
int sensorValue2 = 0;        // value read from the pot
int outputValue2 = 0;        // value output to the PWM (analog out)

void setup() {
  Serial.begin(9600); 
}

void loop() {
  sensorValue = analogRead(analogInPin);
  sensorValue2 = analogRead(analogInPin2);            
  outputValue2 = map(sensorValue2, 0, 1023, 255, 0);
  outputValue = map(sensorValue, 0, 1023, 255, 0);   
  analogWrite(analogOutPin, outputValue); 
  analogWrite(analogOutPin2, outputValue2);          
  delay(2);                     
}

and go this error message "avrdude: ser_send(): write error: sorry no info avail"

Cross Roads, I'll try your new code when I get home in about 8 hours. I appreciate your time

Arduino_User49502:
I ran this code this morning...

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to

const int analogOutPin = 9; // Analog output pin that the LED is attached to
const int analogInPin2 = A1;  // Analog input pin that the potentiometer is attached to
const int analogOutPin2 = 10; // Analog output pin that the LED is attached to
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
int sensorValue2 = 0;        // value read from the pot
int outputValue2 = 0;        // value output to the PWM (analog out)

void setup() {
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(analogInPin);
  sensorValue2 = analogRead(analogInPin2);           
  outputValue2 = map(sensorValue2, 0, 1023, 255, 0);
  outputValue = map(sensorValue, 0, 1023, 255, 0); 
  analogWrite(analogOutPin, outputValue);
  analogWrite(analogOutPin2, outputValue2);         
  delay(2);                   
}




and go this error message "avrdude: ser_send(): write error: sorry no info avail"

See that's important. That isn't an error in your code. That is an avrdude error. That's an error with the program trying to communicate with the board and upload the code that you wrote.