Category: Stem Toys India

Hand Gesture Code Arduino Curiblox

#include <AFMotor.h>

AF_DCMotor Motor(1); // M1 motor
const int trigPin = A0;
const int echoPin = A1;

void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

Motor.setSpeed(200);
Motor.run(RELEASE);
}

long getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

long duration = pulseIn(echoPin, HIGH, 20000); // timeout for safety
long distance = duration * 0.034 / 2;
return distance;
}

void loop() {
long d = getDistance();

Serial.print(“Distance: “);
Serial.println(d);

// — NO OBJECT —
if (d == 0 || d > 30) {
Motor.run(RELEASE); // Stop
}
// — OBJECT VERY CLOSE —
else if (d < 10) {
Motor.run(BACKWARD); // Move backward
}
// — OBJECT IN MID RANGE —
else if (d <= 30) {
Motor.run(FORWARD); // Follow the hand
}

delay(50);
}

Write a Review

Your email address will not be published. Required fields are marked *

Edge Detection or Anti Fall code curiblox

#include <AFMotor.h> AF_DCMotor Motor(1); // M1 motor const int trigPin = A0;.

Line Tracking Code Curiblox

#include <AFMotor.h> AF_DCMotor Motor(1); // M1 motor const int trigPin = A0;.

Object avoidance code curiblox

#include <AFMotor.h> AF_DCMotor Motor(1); // M1 motor const int trigPin = A0;.

hand-gesture-code-curiblox

#include <AFMotor.h> AF_DCMotor Motor(1); // M1 motor const int trigPin = A0;.

Curiblox: India’s Home for Hands-On STEM Toys, STEM

#include <AFMotor.h> AF_DCMotor Motor(1); // M1 motor const int trigPin = A0;.

Item 0.00
Loadding...