Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Peguino RC Remote Brick
#1
Peguino RC Remote Brick

Dieser Peguino Baustein beinhaltet einen RC-Funkempfänger der zu den universellen Fly Sky Fernsteuerungen kompatibel ist. Damit kann beispielsweise ein Ferngesteuertes Auto gelenkt werden.


[Image: Brick_RC_Remote_01b.png]


Es können bis zu sechs Standard Peguino Microservo Bricks angeschlossen werden. Mit einem passenden verbindungskabel kann der Baustein aber auch mit einem Peguino Uno Brick verbunden werden und somit Funktionen über eine Fernsteuerung direkt an den Peguino Uno Brick übermittelt werden.


Beispiel:

Code:
/*
Sweeperbot (C) 2018 by Peguino LTD

Version 0.5

this example has to be revised and is temporary...

*/

int ledPin1 =  2;
int ledPin2 =  3;
int ledPin3 =  4;
int ledPin4 =  5;
int ledPin5 =  6;

int Ch1, Ch2, Ch3, Ch4, Ch5, Ch6; // Channels
int OnboardLED = LOW;             // ledState used to set the LED
int Scheinwerfer = LOW;
int RedLED1 = LOW;
int RedLED2 = LOW;
int BlueLED1 = LOW;
int BlueLED2 = LOW;
unsigned long previousMillis1 = 0;        // will store last time LED was updated
unsigned long previousMillis2 = 0;      
long interval1 = 20;           // interval at which to blink (milliseconds)
long interval2 = 22;
int flicker1 = 0;
int flicker2 = 0;
#define wait 2
#define time 166
int freq = 150;
int auf = 0;
int ab = 0;

void setup() {
 // set the digital pin as output:
 pinMode(ledPin1, OUTPUT);
 pinMode(ledPin2, OUTPUT);
 pinMode(ledPin3, OUTPUT);
 pinMode(ledPin4, OUTPUT);
 pinMode(ledPin5, OUTPUT);
 pinMode(7, INPUT); //I connected this to Chan5 of the Receiver
 pinMode(8, INPUT); //I connected this to Chan6 of the Receiver
 // buzzer 9
 Serial.begin(9600);


}

void loop() {
   int buzzerPin = 9;

 // scheiwerfer ein/aus,
 // int pwm = 0;  // Placeholder for pulsewidth
 Ch1 = pulseIn(7, HIGH, 21000); // Capture pulse width on Channel 1
 Ch2 = pulseIn(8, HIGH, 21000); // Capture pulse width on Channel 2
// Serial.print("Channel 1 ");
//  Serial.println(Ch1);
//  Serial.print("Channel 2  ");
// Serial.println(Ch2);

if(Ch1 > 0){
 if(Ch1 > 1600){ // Scheinwerfer ein / aus
       Scheinwerfer = HIGH;
       Serial.print("Scheinwerfer: EIN ");    
       Serial.println(Ch1);  
       digitalWrite(ledPin5, Scheinwerfer);
   }
   else{
       Scheinwerfer == LOW;
       Serial.print ("Scheinwerfer: AUS ");
       Serial.println(Ch1);  
       digitalWrite(ledPin5, Scheinwerfer);
   }
}

if(Ch2 > 0){
if(Ch2 > 1100){ // Scheinwerfer ein / aus
       Scheinwerfer = HIGH;
     //  Serial.print("Scheinwerfer: EIN ");    
      // Serial.println(Ch1);  
      digitalWrite(ledPin5, Scheinwerfer);
   }
   else{
       Scheinwerfer == LOW;
     //  Serial.print ("Scheinwerfer: AUS ");
    //   Serial.println(Ch1);  
       digitalWrite(ledPin5, LOW);
   }




 
if(Ch2 > 1500){
   // ------ Flashing red and blue LEDs on ----------
   unsigned long currentMillis = millis();
   // red blink
   if (currentMillis - previousMillis1 >= interval1) {
      flicker1 += 1;
      previousMillis1 = currentMillis;
     if (flicker1 == 1) {RedLED1 = HIGH; RedLED2 = LOW;}
     if (flicker1 == 2) {RedLED1 = LOW; RedLED2 = HIGH;}
     if (flicker1 == 3) {RedLED1 = HIGH; RedLED2 = LOW;}
     if (flicker1 == 4) {RedLED1 = LOW; RedLED2 = HIGH;}
     if (flicker1 == 5) {RedLED1 = HIGH; RedLED2 = LOW;}
     if (flicker1 == 6) {RedLED1 = HIGH; RedLED2 = LOW;}
     if (flicker1 == 7) {RedLED1 = HIGH; RedLED2 = LOW;}
     if (flicker1 == 8) {RedLED1 = LOW; RedLED2 = HIGH;}
     if (flicker1 == 9) {RedLED1 = LOW; RedLED2 = HIGH;}
     if (flicker1 >= 10) {RedLED1 = LOW; RedLED2 = HIGH; flicker1 =0;}
     digitalWrite(ledPin1, RedLED1);
     digitalWrite(ledPin2, RedLED2);
   }
   // blue blink
   if (currentMillis - previousMillis2 >= interval2) {
      flicker2 += 1;
      previousMillis2 = currentMillis;
     if (flicker2 == 1) {BlueLED1 = HIGH; BlueLED2 = LOW;}
     if (flicker2 == 2) {BlueLED1 = LOW; BlueLED2 = HIGH;}
     if (flicker2 == 3) {BlueLED1 = HIGH; BlueLED2 = HIGH;}
     if (flicker2 == 4) {BlueLED1 = LOW; BlueLED2 = HIGH;}
     if (flicker2 == 5) {BlueLED1 = HIGH; BlueLED2 = LOW;}
     if (flicker2 == 6) {BlueLED1 = LOW; BlueLED2 = HIGH;}
     if (flicker2 == 7) {BlueLED1 = HIGH; BlueLED2 = LOW;}
     if (flicker2 == 8) {BlueLED1 = LOW; BlueLED2 = HIGH;}
     if (flicker2 == 9) {BlueLED1 = LOW; BlueLED2 = LOW;}
     if (flicker2 >= 10) {BlueLED1 = LOW; BlueLED2 = HIGH; flicker2 =0;}
     digitalWrite(ledPin3, BlueLED1);
     digitalWrite(ledPin4, BlueLED2);
    // Serial.print ("Blinker: ON ");
   //  Serial.println(Ch2);
   }
 }
 else {
   // ------ Flashing red and blue LEDs off ----------
     RedLED1 = LOW;
     RedLED2 = LOW;
     BlueLED1 = LOW;
     BlueLED2 = LOW;
     digitalWrite(ledPin1, RedLED1);
     digitalWrite(ledPin2, RedLED2);
     digitalWrite(ledPin3, BlueLED1);
     digitalWrite(ledPin4, BlueLED2);
   // Serial.print ("Blinker: OFF ");
  //  Serial.println(Ch2);
   }
}  

if(Ch2 > 1800){
 
 if (freq < 1800 && auf == 0)  
 {
   freq += 50;
   tone(9, freq, time);
   if (freq >= 1800)
   {auf = 1; ab = 0;}
 }
 else
 {
   freq -= 45;
   tone(9, freq, time);
   if (freq <= 450)
   {auf = 0; ab = 1;}
 }
}
 if (Ch2 < 1800 && auf == 1 || ab == 1)
   {
   freq -= 10;
   tone(9, freq, time);
   if (freq <= 60)
   {auf = 0; ab = 0;}
 }
 
 //delay(10);
 //  PrintRC(); //Print Values for RC Mode Diagnostics
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)