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

Dieser Peguino Baustein beinhaltet einen (Infrarot-) Lichtreflexionssensor um Helligkeitsschankungen und damit Objekte im Nahbereich zu erkennen. Damit ist es beispielsweise möglich einen Roboter eine schwarzen Linie auf weißem Grund folgen zu lassen.

[Image: Brick_Miniprox_01b.png]

Schaltplan:

[Image: Miniprox_schematic_01b.png]

Beispiel für Peguino Uno Nano und Peguino Uno ESP32 V1:

Stecke den Peguino Microprox Baustein an Port C3 des Peguino Uno Bausteins. Kopiere das Programmskript unten (CTRL+C) und fühe es in die Arduino IDE ein (CTRL+V). Kompiliere und übertrage das fertige Programm mit der Arduino IDE auf das Peguino Uno Board. Mit dem Serial Monitor oder dem Serial Plotter der Arduino IDE kannst Du nun die gemessenen Werte des Lichtsensors sichtbar machen. Wird ein Peguino RGB LED Brick in Port F eingesteckt ändert sich die Lichtfarbe entsprechend.


1. Programmskript für einen Peguino Uno Nano Baustein:
Code:
/*
 Microprox Brick
 (C) 2018 by Peguino LTD
 Connect the Microprox Brick to port C3
 Connect the RGB LED Brick to port F
 Version 1

 Note: Use the Serial Plotter to see the values


 Peguino Uno Nano Board Pinout
            ┌─╥─┐
    D_13  1 │     │ 30  D_12
   3.3 V  2 │     │ 29  D_11
    AREF  3 │     │ 28  D_10
D_14 A_0  4 │     │ 27  D_9
D_15 A_1  5 │     │ 26  D_8
D_16 A_2  6 │     │ 25  D_7
D_17 A_3  7 │     │ 24  D_6
D_18 A_4  8 │     │ 23  D_5
D_19 A_5  9 │     │ 22  D_4
     A_6 10 │     │ 21  D_3
     A_7 11 │     │ 20  D_2
      5V 12 │     │ 19  GND
   Reset 13 │     │ 18  Reset
     GND 14 │     │ 17  D_0 RX
Power In 15 │     │ 16  D_1 TX
            └───┘
 Visit https://www.peguino.com            
*/




#define ANALOG_PIN_0 2               // Analog Input from A_2 which is physically located on Pin 6 and available on Port C3
int analog_value = 0;
int triggerline = 0;

const int ledPin1 = 12; // red
const int ledPin2 = 11; // green
const int ledPin3 = 13; // blue


void setup()
{
 // initialize digital pin ledPin as an output.
 pinMode(ledPin1, OUTPUT);
 pinMode(ledPin2, OUTPUT);
 pinMode(ledPin3, OUTPUT);
 digitalWrite(ledPin1, HIGH);
 digitalWrite(ledPin2, HIGH);
 digitalWrite(ledPin3, HIGH);

 Serial.begin(115200);                 // Press Ctrl+Shift+L and set the serial monitor to the same baud rate!
 delay(1000);                          // give me time to bring up serial monitor
 Serial.println("Microprox 1");
}

void loop()
{
analog_value = analogRead(ANALOG_PIN_0);
 Serial.print(analog_value);          // the first variable for plotting
 Serial.print(",");                   // seperator
 Serial.println(triggerline);

 if (analog_value > 600) {           // number taken by measuring white paper sheet. A black line might below this value....    
     triggerline = 800;          
     digitalWrite(ledPin1, LOW);     // Red light on
     digitalWrite(ledPin2, HIGH);    // Green light off
     }
else{
     triggerline = 0;
     digitalWrite(ledPin1, HIGH);    // Red light off
     digitalWrite(ledPin2, LOW);     // Green light on
     }
 delay(100);
}



2. Programmskript für einen Peguino Uno ESP32 Baustein:
Code:
/*
  Microprox Brick
  (C) 2018 by Peguino LTD
  Connect the Microprox Brick to port C3
  Connect the RGB LED Brick to port F
  Version 1
 
  Note: Use the Serial Plotter to see the values


  Peguino Uno ESP 32 Development Board Pinout
            ┌─╥─┐
  3.3     1 │     │ 30  5V
  GND     2 │     │ 29  GND
  GPIO15  3 │     │ 28  GPIO13
  GPIO2   4 │     │ 27  GPIO12
  GPIO4   5 │     │ 26  GPIO14
  GPIO16  6 │     │ 25  GPIO27
  GPIO17  7 │     │ 24  GPIO26
  GPIO5   8 │     │ 23  GPIO25
  GPIO18  9 │     │ 22  GPIO33
  GPIO19 10 │     │ 21  GPIO32
  GPIO21 11 │     │ 20  GPIO35
  GPIO3  12 │     │ 19  GPIO34
  GPIO1  13 │     │ 18  GPIO39
  GPIO22 14 │     │ 17  GPIO36
  GPIO23 15 │     │ 16  Chip enable
            └───┘
  Visit https://www.peguino.com          
*/




#define ANALOG_PIN_0 36               // Analog Input from GPIO 36 which is physically located on Pin 17 and available on Port C3
int analog_value = 0;
int triggerline = 0;

// ledPin refers to ESP32 GPIO 12, 13 and 14
const int ledPin1 = 13; // blue
const int ledPin2 = 12; // green
const int ledPin3 = 14; // red


void setup()
{
  // initialize digital pin ledPin as an output.
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  digitalWrite(ledPin1, HIGH);
  digitalWrite(ledPin2, HIGH);
  digitalWrite(ledPin3, HIGH);
 
  Serial.begin(115200);                 // Press Ctrl+Shift+L and set the serial monitor to the same baud rate!
  delay(1000);                          // give me time to bring up serial monitor
  Serial.println("Microprox 1");
}

void loop()
{
analog_value = analogRead(ANALOG_PIN_0);
  Serial.print(analog_value);          // the first variable for plotting
  Serial.print(",");                   // seperator
  Serial.println(triggerline);

  if (analog_value > 800) {           // number taken by measuring white paper sheet. A black line might below this value....    
      triggerline = 1000;          
      digitalWrite(ledPin1, LOW);     // Red light on
      digitalWrite(ledPin2, HIGH);    // Green light off
      }
 else{
      triggerline = 0;
      digitalWrite(ledPin1, HIGH);    // Red light off
      digitalWrite(ledPin2, LOW);     // Green light on
      }
  delay(100);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)