fesdv (copy) — Arduino Uno simulation

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by nicholas-han7009.

Components

Sketch code

// Arduino Blink Example
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
#include <Servo.h>
#define sensorCahaya A0
#define sensorLembab A1
LiquidCrystal_PCF8574 lcd(0x27);
Servo myServo;
int pinServo = 4;
int pinMotor = 7;

void setup() {
  pinMode(pinMotor,OUTPUT);
  lcd.begin(16,2);
  lcd.setBacklight(255);
  lcd.clear();
  myServo.attach(pinServo);
}

void loop() {
  
  int cahaya = analogRead(sensorCahaya);
  int tanah = analogRead(sensorLembab);

  if(cahaya > 30)
  {
    myServo.write(0);
  }
  else
  {
    myServo.write(90);
  }

  if(tanah < 400)
  {
    digitalWrite(pinMotor, HIGH);
  }
  else
  {
    digitalWrite(pinMotor, LOW);
  }
  display(tanah,cahaya);
}


void display(int tanah, int cahaya)
{
  lcd.clear();
  lcd.home();
  lcd.print("kelembapan:");
  lcd.setCursor(0, 1);
  lcd.print(tanah);
  delay(500);

  lcd.clear();
  lcd.home();
  lcd.print("cahaya : ");
  lcd.setCursor(0, 1);
  lcd.print(cahaya);
  delay(500);
}

More projects by nicholas-han7009