Hello!
So I have my solderless breadboard circuit up and running how I want, I just was wondering if there was any programs that might be able to take my breadboard circuit and put into solderable breadboard layout?
I’ve attempted to transfer the circuit but I know something is connected incorrectly because the “Reset button” resets the board correctly, but every time I press it both the void Ultrasonic and void Photocell automatically turn on.
Note: The solderable breadboards I’m using dont have connected rails like the solderless ones do…
Any guidance on how to wire this correctly would be really appreciated!
#include <NewPing.h>
#define TRIGGER_PIN 10 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 9 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
const byte buttonPin[] = {A15, A14, A13, A12}; // button pins in array
const byte ForwardPin = 12;
const byte ReversePin = 11;
//Variables for Button Push Counter
int myCounter = 0; //declare your variable myCounter and set to 0
//Constants for Photocell
const byte pResistor [3] = { A0, A1, A2 }; // Photoresistor at Arduino analog pins
//Variables for Photocells
int SensorValue1;
int SensorValue2;
int SensorValue3; // Store value from photoresistor (0-1023)
// Variables will change:
int buttonState[] = {0, 0, 0, 0}; // current state of the button1
int lastButtonState[] = {0, 0, 0, 0}; // previous state of the button1
int buttonPushCounter[] = {0, 0, 0, 0};
void setup() {
// initialize the button pin as a input:
pinMode(buttonPin[0], INPUT);
pinMode(buttonPin[1], INPUT);
pinMode(buttonPin[2], INPUT);
pinMode(buttonPin[3], INPUT);
pinMode(buttonPin[4], INPUT);
pinMode(pResistor[0], INPUT);
pinMode(pResistor[1], INPUT);
pinMode(pResistor[2], INPUT);
// initialize the LED as an output:
pinMode(ForwardPin, OUTPUT);
pinMode(ReversePin, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
// read the pushbutton input pin:
buttonState[0] = digitalRead(buttonPin[0]);
buttonState[1] = digitalRead(buttonPin[1]);
buttonState[2] = digitalRead(buttonPin[2]);
buttonState[3] = digitalRead(buttonPin[3]);
if (buttonState[0] != lastButtonState[0]) {
if (buttonState[0] == HIGH) {
buttonPushCounter[0]++;
Serial.println(buttonPushCounter[0]);
}
delay(10);
}
if (buttonState[1] != lastButtonState[1]) {
if (buttonState[1] == HIGH) {
buttonPushCounter[1]++;
Serial.print("Forward On");
Serial.println(buttonPushCounter[1]);
}
delay(10);
}
if (buttonState[2] != lastButtonState[2]) {
if (buttonState[2] == HIGH) {
buttonPushCounter[2]++;
Serial.print("Reverse On");
Serial.println(buttonPushCounter[2]);
}
delay(10);
}
if (buttonState[3] != lastButtonState[3]) {
if (buttonState[3] == HIGH) {
buttonPushCounter[3]++;
Serial.println(buttonPushCounter[3]);
}
delay(10);
}
lastButtonState[0] = buttonState[0]; // save the current state as the last state, for next time through the loop
lastButtonState[1] = buttonState[1];
lastButtonState[2] = buttonState[2];
lastButtonState[3] = buttonState[3];
if (buttonPushCounter[0] % 2 == 0) {
MotorForwardCode();
}
if (buttonPushCounter[1] % 2 == 0) {
MotorReverseCode();
}
if (buttonPushCounter[2] % 2 == 0) {
PhotoCellCode();
}
if (buttonPushCounter[3] % 2 == 0) {
UltrasonicCode();
}
else {
digitalWrite(ForwardPin, LOW);
digitalWrite(ReversePin, LOW);
}
}
void MotorForwardCode() {
digitalWrite(ForwardPin, HIGH);
}
void MotorReverseCode() {
digitalWrite(ReversePin, HIGH);
}
void PhotoCellCode() {
SensorValue1 = analogRead(pResistor[0]); //get the value from input pin 1
SensorValue2 = analogRead(pResistor[1]);
SensorValue3 = analogRead(pResistor[2]);
if (SensorValue1 < 15 && SensorValue2 < 300) { //if two are dark turn motor off
digitalWrite(ForwardPin, LOW);
digitalWrite(ReversePin, LOW); // stop reverse
}
else if (SensorValue1 < 15 && SensorValue3 < 25) {
digitalWrite(ForwardPin, LOW);
digitalWrite(ReversePin, LOW); // stop reverse
}
else if (SensorValue2 < 200 && SensorValue3 < 25) {
digitalWrite(ForwardPin, LOW);
digitalWrite(ReversePin, LOW); // stop reverse
}
else {
digitalWrite(ForwardPin, HIGH); //else, keep the motor on
}
Serial.print(SensorValue1);
Serial.print(",");
Serial.print(SensorValue2);
Serial.print(",");
Serial.println(SensorValue3);
}
void UltrasonicCode() {
delay(29); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
Serial.print("Ping: ");
Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
if (sonar.ping_cm() <= 10) {
digitalWrite(ForwardPin, LOW);
}
else {
digitalWrite(ForwardPin, HIGH);
}