Pete Perri
Created March 20, 2023

Project 06 - DIG3602C

Peter Perri UCF-Spring 2023-DIG3602C-Davis Project 06

19
Project 06 - DIG3602C

Things used in this project

Hardware components

Buzzer, Piezo
Buzzer, Piezo
×1
Photo resistor
Photo resistor
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

project6_Jx1uKD5sJR.fzz

Code

Untitled file

C/C++
int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;
const int ledPin = 13;

void setup() {

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);

  while (millis() < 5000) {
    sensorValue = analogRead(A0);

    if (sensorValue > sensorHigh) {
      sensorHigh = sensorValue;
    }

    if (sensorValue < sensorLow) {
      sensorLow = sensorValue;
    }
  }
  digitalWrite(ledPin, LOW);
 }

void loop() {
  sensorValue=analogRead(A0);
  tone(8, map(sensorValue, sensorLow, sensorHigh, 50, 4000);, 20);
  delay(10);
 }

Credits

Pete Perri
13 projects • 0 followers

Comments