the code below was working fine on my mega using pins A0 and 40 and 50 on off
im just reading a pot value of a joy stick and spliting it in to 2 derctions useing relays hooked to 40 and 50 on the old porgram for the mega
now ive made some changes to the code and uploaded to to an attiny85
now i need a pin for my pot pin from the joy stick
and another for my bacwards / forwards toggle relay
and the last pin to cut power when the joy stick pot reads between 450 and 500
so i changed the int pin for A0 to 2;
and my toggle deriction to 1 ;
and relay to cut power to 0;
not working quite the way i pland on the attiny 85
think im just confused on what pins do what and how the are called out in the program for the at85 ?
first old code then what i up loaded to the attiny 85
next the revsied code for the attiny 85
*/
// These constants won't change:
const int analogPin = A0;
const int derictPin = A0;
// pin that the sensor is attached to
const int ledPin = 50; // pin that the LED is attached to has derction of dc motor relay
const int threshold = 600; // an arbitrary threshold level that's in the range of the analog input
int toggle = 40; // motor on / off
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(toggle, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
}
void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
// if the analog value is high enough, turn on the LED:
if (analogValue < 405) {
Serial.println(analogValue);
analogRead(derictPin);
Serial.println(derictPin);
analogRead(analogPin);
int analogValue = analogRead(A0);
analogValue = map(analogRead(A0), 440, 0, 255, 0);
digitalWrite(ledPin, HIGH);
analogWrite(12,analogValue/4-60);
digitalWrite(toggle, HIGH);
Serial.println(analogValue);
analogRead(derictPin);
Serial.println(derictPin);
delay(30);
}
else if (analogValue > 505)
{
Serial.println(analogValue);
analogRead(derictPin);
Serial.println(derictPin);
analogRead(analogPin);
int analogValue = analogRead(analogPin);
analogValue = map(analogRead(A0), 450, 1023, 255, 0);
analogWrite(12,analogValue/4-60);
digitalWrite(ledPin,LOW); // led pin toggles revers polarity of dc motor relay for now
digitalWrite(toggle, HIGH);
Serial.println(analogValue);
analogRead(derictPin);
Serial.println(derictPin);
delay(30);
}
else
{
Serial.println(analogValue);
analogRead(derictPin);
Serial.println(derictPin);
analogRead(analogPin);
int analogValue = analogRead(analogPin);
analogValue = map(analogRead(A0), 431, 449, -1, 1);
analogRead(analogPin);
digitalWrite(toggle,LOW);
// print the analog value:
Serial.println(analogValue);
analogRead(derictPin);
Serial.println(derictPin);
delay(30);
}
}
const int analogPin = 2;
const int derictPin = 2;
// pin that the sensor is attached to
const int ledPin = 0; // pin that the LED is attached to has derction of dc motor relay
const int threshold = 600; // an arbitrary threshold level that's in the range of the analog input
int toggle = 1; // motor on / off
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(toggle, OUTPUT);
// initialize serial communications:
}
void loop() {
// read the value of the potentiometer:
int analogValue = analogRead(analogPin);
// if the analog value is high enough, turn on the LED:
if (analogValue < 405) {
analogRead(derictPin);
analogRead(analogPin);
int analogValue = analogRead(2);
analogValue = map(analogRead(2), 440, 0, 255, 0);
digitalWrite(ledPin, HIGH);
analogWrite(12,analogValue/4-60);
digitalWrite(toggle, HIGH);
analogRead(derictPin);
delay(30);
}
else if (analogValue > 505)
{
analogRead(derictPin);
analogRead(analogPin);
int analogValue = analogRead(analogPin);
analogValue = map(analogRead(2), 450, 1023, 255, 0);
analogWrite(12,analogValue/4-60);
digitalWrite(ledPin,LOW); // led pin toggles revers polarity of dc motor relay for now
digitalWrite(toggle, HIGH);
analogRead(derictPin);
delay(30);
}
else
{
analogRead(derictPin);
analogRead(analogPin);
int analogValue = analogRead(analogPin);
analogValue = map(analogRead(2), 431, 449, -1, 1);
analogRead(analogPin);
digitalWrite(toggle,LOW);
// print the analog value:
analogRead(derictPin);
delay(30);
}
}