Помогите переделать код под attiny 2313
- Войдите на сайт для отправки комментариев
Вс, 11/01/2015 - 18:52
Всем привет. Собрал готове устройство на arduino uno v3 + PIR датчик + TIP120 (транзисторы). Хочу все это дело перенести на attiny 2313 Помогите с кодом - может уже кто-то делал такое???
/* Arduino with PIR motion sensor For complete project details, visit: http://RandomNerdTutorials.com/pirsensor Modified by Rui Santos based on PIR sensor by Limor Fried http://allaboutee.com/2011/05/16/arduino-tutorial-rgb-led/ http://randomnerdtutorials.com/arduino-with-pir-motion-sensor/ */ //int led = 13; // the pin that the LED is atteched to int sensor = 2; // the pin that the sensor is atteched to int state = LOW; // by default, no motion detected int val = 0; // variable to store the sensor status (value) #define REDPIN 5 #define GREENPIN 6 #define BLUEPIN 3 #define FADESPEED 5 // чем выше число, тем медленнее будет fade-эффект void setup() { pinMode(REDPIN, OUTPUT); pinMode(GREENPIN, OUTPUT); pinMode(BLUEPIN, OUTPUT); //pinMode(led, OUTPUT); // initalize LED as an output pinMode(sensor, INPUT); // initialize sensor as an input Serial.begin(9600); // initialize serial } void loop(){ int r, g, b; val = digitalRead(sensor); // read sensor value if (val == HIGH) { for (r = 0; r < 256; r++) { analogWrite(REDPIN, r); delay(FADESPEED); } for (b = 255; b > 0; b--) { analogWrite(BLUEPIN, b); delay(FADESPEED); } for (g = 0; g < 256; g++) { analogWrite(GREENPIN, g); delay(FADESPEED); } // fade от желтого к зеленому for (r = 255; r > 0; r--) { analogWrite(REDPIN, r); delay(FADESPEED); } // fade от зеленого к зеленовато-голубому for (b = 0; b < 256; b++) { analogWrite(BLUEPIN, b); delay(FADESPEED); } // fade от зеленовато-голубого к голубому for (g = 255; g > 0; g--) { analogWrite(GREENPIN, g); delay(FADESPEED); } // check if the sensor is HIGH // digitalWrite(led, HIGH); // turn LED ON // delay(100); // delay 100 milliseconds if (state == LOW) { Serial.println("Motion detected!"); state = HIGH; // update variable state to HIGH } } else { analogWrite(GREENPIN, LOW); analogWrite(BLUEPIN, LOW); analogWrite(REDPIN,LOW); // digitalWrite(led, LOW); // turn LED OFF delay(400); // delay 200 milliseconds if (state == HIGH){ Serial.println("Motion stopped!"); state = LOW; // update variable state to LOW } } }
А непроще в ATMEGу 8 это залить?
Ее к сожалению нету в наличии (((