Sad Cat Fixer
Code :
/**************************************************************/
//Name: Sad Cat Fixer
/*Description: Toy that spins a servo moter with a led/laser on it that distracts the cat
//Programmer: Suhil Sharifi
//Date: 2022.1.20
//Pins connected(7,8,9)
/**************************************************************/
#include
/*************************************************/
//Global Variables:
/*************************************************/
Servo myservo; int value; double angle; const int ledPin = 8;// pin number for led
/**************************************************************/
//Setup Function: This code runs once
/**************************************************************/
void setup() { Serial.begin(9600); myservo.attach(9); pinMode(ledPin, OUTPUT); // sets ledPin as an output }
/**************************************************************/
//Loop Function: This code runs forever
/**************************************************************/
void loop() { value = digitalRead(7); if(value==HIGH) { angle = 360; digitalWrite(ledPin, HIGH);// turn the } else { angle = 0; } Serial.println(angle); myservo.write(angle); delay(100);
if (value == HIGH){ // checks if the button was pressed digitalWrite(ledPin, HIGH);// turn the red pin on
} }