Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.5 kB
7
Indexable
void setup() {
//for(int i=5;i<11;i++) pinMode(i, OUTPUT);
pinMode(5, OUTPUT); //analogWrite(5, 80);
pinMode(6, OUTPUT); //analogWrite(6, 80);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);
//analogWrite(9, 255);
//analogWrite(10, 255);
Serial.begin(9600);
}

void loop() {
  if(Serial.available()>0){
  int m = Serial.read();
    if(m == '1') {while(m=='1') {Uzprieksu(10);m = Serial.read();}}
    if(m == '2') {while(m=='2') {Atpakal(10);m = Serial.read();}}
    if(m == '3') {while(m=='3') {Palabi(10);m = Serial.read();}}
    if(m == '4') {while(m=='4') {Pakreisi(10);m = Serial.read();}}
    if(m == '5') {while(m=='5') {Stop(10);m = Serial.read();}}}
}
void Uzsak(){
  for(int i=80;i<=200;i=i+5){
    analogWrite(5,i);
    analogWrite(6,i);
    delay(50);
    }
}
void Uzprieksu(int k){
  digitalWrite(A0, HIGH);
  digitalWrite(A1, LOW);
  digitalWrite(A3, HIGH);
  digitalWrite(A2, LOW);
  Uzsak();
  delay(k);
}
void Atpakal(int k){
  digitalWrite(A0, LOW);
  digitalWrite(A1, HIGH);
  digitalWrite(A3, LOW);
  digitalWrite(A2, HIGH);
  Uzsak();
  delay(k);
}
void Palabi(int k){
  digitalWrite(A1, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A0, HIGH);
  digitalWrite(A3, LOW);
  Uzsak();
  delay(k);
}
void Pakreisi(int k){
  digitalWrite(A3, HIGH);
  digitalWrite(A0, LOW);
  digitalWrite(A1, LOW);
  digitalWrite(A2, LOW);
  Uzsak();
  delay(k);
}
void Stop(int k){
  digitalWrite(A0, LOW);
  digitalWrite(A1, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(A3, LOW);
  delay(k);
}