Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define ldrPin A0
- #define pb1Pin 2
- #define pb2Pin 3
- #define ledPin 9
- int ldrValue = 0;
- int pb1Value = 0;
- int pb2Value = 0;
- void setup() {
- Serial.begin(9600);
- pinMode(pb1Pin, INPUT);
- pinMode(pb2Pin, INPUT);
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- ldrValue = analogRead(ldrPin);
- if (ldrValue < 200) { // יש חומר גלם
- Serial.println("There is stock on the machine");
- pb1Value = digitalRead(pb1Pin);
- pb2Value = digitalRead(pb2Pin);
- if (pb1Value == HIGH && pb2Value == HIGH) { //שני כפתורים לחוצים
- Serial.println("Start motor");
- digitalWrite(ledPin, HIGH);
- }
- else {
- Serial.println("Stop motor");
- digitalWrite(ledPin, LOW);
- }
- }
- else {
- Serial.println("There is NO stock on the machine");
- Serial.println("Stop motor");
- digitalWrite(ledPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement