Greta Galli
Published © GPL3+

A robot friend

This is a project about a robot made for people who feel lonely.

BeginnerFull instructions provided1 hour2,499
A robot friend

Things used in this project

Hardware components

Arduino MKR WiFi 1010
Arduino MKR WiFi 1010
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Hand tools and fabrication machines

cardboard
Tape, Scotch
Tape, Scotch

Story

Read more

Schematics

Full circuit

Code

Full code

Arduino
#include <Servo.h>
#include <WiFiNINA.h>
#include <SPI.h>
#include <BlynkSimpleWiFiNINA.h>
#define BLYNK_PRINT Serial
#define trig 11
#define echo 10

Servo servo;

char auth[] = "Auth code of your blynk app";


unsigned long durata;
float distanza;

char ssid[] = "ssid of your wifi";
char pass[] = "password of your wifi"; 


void setup() {
  // put your setup code here, to run once:
  servo.attach(9);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
}

void loop() {
  // put your main code here, to run repeatedly:
  Blynk.run();
  
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  durata = pulseIn(echo, HIGH);
  distanza = durata*0.0347/2;
  Serial.println(distanza);
  if(distanza < 10){
    
    Blynk.notify("text on the notification");
    
      for(int j=0; j<2; j++){
        for(int i= 40; i<100; i++){
          servo.write(i);
          delay(10);
        }
        for(int i= 100; i>=40; i--){
          servo.write(i);
          delay(10);
        }
      }
  }
  
}

Credits

Greta Galli

Greta Galli

4 projects • 21 followers
I am an eighteen italian girl and I like robotics and mechatronics. I've create a cybernetic hand only with Lego. Enjoy :)

Comments