I'm having trouble by programming & creating a circuit diagram by using an SG-5010 Double ball bearing servo motor & a relay module that is controlled by an inductive proximity sensor.
The flow would be;
If the inductive proximity sensor will sense a metallic waste it would give a signal to my relay to my servo motor that would rotate so that the waste would drop into its METALLIC bin instead of NON metallic.
Could anyone help me? thank you Aduino staff's and members as well.
My components used;
Arduino Uno
SG-5010 3 pins Servo Motor
SRD-05VDC-SL-C Relay Module
Inductive Proximity Sensor
Post your code. Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Describe what the code actually does and how that differs from what you want.
Post a schematic. Include all parts and their part numbers and/or values and all power supplies. Hand drawn, photographed and posted is OK. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
yes our servo works properly and as well as our inductive proximity sensor and also the relay, i think i had a problem on my program? i can't determine what the exact problem is :<
When your code has an error that you want help with you should post the code. Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
The Servo library has example code that will show how to use the library.
Here is your code with the Servo library (untested):
#include <Servo.h>
const byte servoPin = 7; //
const byte ledPin = 13;
const byte inpin = 2; // proximity sensor connected with the pin 2
Servo servo;
int val = 0; // this variable will read the value from the sensor
void setup()
{
pinMode(ledPin, OUTPUT);
servo.write(90); // initial position
servo.attach(servoPin);
}
void loop()
{
val = digitalRead(inpin);
if (val == HIGH)
{
servo.write(10);
delay(1000);
}
else
{
servo.write(90);
delay(1000);
}
}