IoT simulation which will record the movement and orientation of phone and give feedback

IoT simulation which will record the movement and  orientation of phone and give feedback in Tinker Cad with code




Tinker Cad Circuit Design:


Component Requirements:

1) Arduino Uno R3
2) Micro Servo
3) Potentiometer 250 Kilo Ohms

Code for the Circuit:

#include <Servo.h>
#include <SoftwareSerial.h>

int pos = 0;
int sensorValue = 0;
int i = 0;
Servo servo_9;

void setup(){
  servo_9.attach(9);
  pinMode(A0, INPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  
   sensorValue = analogRead(A0);
   pos = map(sensorValue,0,1023,0,180);
  
  for (i = 0; i <= pos; i++) {
  if(i == 90){
    Serial.println("Landscape");
    } else if( i == 180 || i == 0){
      Serial.println("Portrait");
    }
    servo_9.write(i);
    delay(15); 
  }
  for (i= pos; i >= 0; i --) {
    if(i == 90){
    Serial.println("Landscape");
    } 
    servo_9.write(i);
    delay(15); 
  }
}


Comments

Popular posts from this blog

Installing Hyper Ledger Fabric on Windows 10

Add the sensors to the Robot object and develop the line-following behavior code.

Create and deploy a block chain network using Hyperledger Fabric SDK for Java on Ubuntu 22.04 LTS