Advertisement
Guest User

Drive

a guest
Aug 23rd, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement