O Level Exam : Practical Question
📝 HTML
🎨 CSS
⚡ Java Script
#include <Servo.h> // Create a Servo object Servo myservo; void setup() { myservo.attach(9); // Optionally, move the servo to the initial position myservo.write(0); // Move to 0 degrees Serial.begin(9600); } void loop() { for(int a=1;a<=180;a=a+10) { Serial.println(a); myservo.write(a); delay(10); } delay(1000); for(int a=180;a>=0;a=a-10) { Serial.println(a); myservo.write(a); delay(10); } delay(1000); }
▶ Run Code
🖥 Output: