11-09-2018, 01:14 PM
(This post was last modified: 12-07-2018, 01:40 PM by Peguinohero.)
Peguino Miniprox Brick
This unit houses and delivers a passive infrared reflexive sensor to detect close objects or brightness differences enable your project e.g. to drive a robot above a black line on a white ground.
![[Image: Brick_Miniprox_01b.png]](https://www.peguino.com/chat/images/Brick_Miniprox_01b.png)
Schematic:
![[Image: Miniprox_schematic_01b.png]](https://www.peguino.com/chat/images/Miniprox_schematic_01b.png)
Examples for Peguino Uno Nano and ESP32 V1:
Connect the Microprox Brick to the Peguino Uno Brick Port C3. You could add a RGB LED Brick on port F. Copy and paste the code below into the Arduino IDE and upload it to the Peguino Uno Brick board.
1. Code example for the Peguino Uno Nano version:
2. Code example for the Peguino Uno ESP 32 version:
This unit houses and delivers a passive infrared reflexive sensor to detect close objects or brightness differences enable your project e.g. to drive a robot above a black line on a white ground.
![[Image: Brick_Miniprox_01b.png]](https://www.peguino.com/chat/images/Brick_Miniprox_01b.png)
Schematic:
![[Image: Miniprox_schematic_01b.png]](https://www.peguino.com/chat/images/Miniprox_schematic_01b.png)
Examples for Peguino Uno Nano and ESP32 V1:
Connect the Microprox Brick to the Peguino Uno Brick Port C3. You could add a RGB LED Brick on port F. Copy and paste the code below into the Arduino IDE and upload it to the Peguino Uno Brick board.
1. Code example for the Peguino Uno Nano version:
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. Code example for the Peguino Uno ESP 32 version:
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);
}