Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ds1 = A2; //pin that indicates the existence of the CD inside the drive if HIGH and its inexistance otherwise
- int d1 = A3; //pin connected to the wire that if connected to ground ejects the CD
- void setup() {
- Serial.begin(9600);
- pinMode(ds1, INPUT);
- pinMode(d1, OUTPUT);
- while((!analogRead(ds1))) //if the CD isn't inside the drive wait
- {}
- }
- void loop() {
- analogWrite(d1,0); //eject CD
- delay(500);
- while(!analogRead(ds1)) //if the CD isn't inside the drive wait
- {}
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement