SHARE
TWEET

Drive

a guest Aug 23rd, 2018 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int ds1 = A2; //pin that indicates the existence of the CD inside the drive if HIGH and its inexistance otherwise
  2. int d1 = A3;  //pin connected to the wire that if connected to ground ejects the CD
  3.  
  4.  
  5. void setup() {
  6.    Serial.begin(9600);
  7.   pinMode(ds1, INPUT);
  8.   pinMode(d1, OUTPUT);
  9.   while((!analogRead(ds1))) //if the CD isn't inside the drive wait
  10.   {}
  11. }
  12.  
  13. void loop() {
  14.                 analogWrite(d1,0); //eject CD
  15.                 delay(500);
  16.                 while(!analogRead(ds1)) //if the CD isn't inside the drive wait
  17.                 {}
  18.                 delay(1000);
  19.                
  20.  
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top