{"id":21451766,"url":"https://github.com/ostad-ai/arduino-tutorial","last_synced_at":"2025-10-27T06:08:24.424Z","repository":{"id":193302673,"uuid":"688523738","full_name":"ostad-ai/Arduino-Tutorial","owner":"ostad-ai","description":"Here, We work with the Arduino boards","archived":false,"fork":false,"pushed_at":"2023-10-07T17:59:22.000Z","size":775,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T12:29:44.559Z","etag":null,"topics":["arduino","code","keypad","lcd","led","servo-motor","slide-potentiometer","slide-switch","tutorial","ultrasonic-range-finder"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ostad-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-07T14:20:35.000Z","updated_at":"2023-10-07T18:01:46.000Z","dependencies_parsed_at":"2024-11-23T06:46:03.419Z","dependency_job_id":null,"html_url":"https://github.com/ostad-ai/Arduino-Tutorial","commit_stats":null,"previous_names":["ostad-ai/arduino-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostad-ai%2FArduino-Tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostad-ai%2FArduino-Tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostad-ai%2FArduino-Tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostad-ai%2FArduino-Tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ostad-ai","download_url":"https://codeload.github.com/ostad-ai/Arduino-Tutorial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243964473,"owners_count":20375784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","code","keypad","lcd","led","servo-motor","slide-potentiometer","slide-switch","tutorial","ultrasonic-range-finder"],"created_at":"2024-11-23T04:25:47.557Z","updated_at":"2025-10-27T06:08:24.328Z","avatar_url":"https://github.com/ostad-ai.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arduino Tutorial\n1. **LED Blinking:** We use an LED (Light Emitting Diode), which is connected to the Arduino via a resistor. The resistor limits the current that flows through the LED to prevent it from burning by too much current. \n - The **pinMode()** defines the pin of Arduino that is connected to the LED as **OUTPUT**, **INPUT**, or **INPUT_PULLUP**. \n - Function **delay()** pauses the program for the amount of time in milliseconds.\n - Function **digitalWrite()** sets the value of the given digital pin as HIGH or LOW.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/374869964416433153\" \u003eLED Blinking: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/1.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n2. **Slide switch to turn ON and OFF an LED:** We use a slide switch to turn an LED ON and OFF. As before, the LED is connected to the Arduino via a resistor. \n - We define the pin of Arduino that is connencted to the common contact of the switch, as **INPUT_PULLUP**, which means that this pin is an input, and it is HIGH by default, if it is not connected to the GROUND.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/375711320031687681\" \u003eSlide switch to toggle LED: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/2.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n3. **Controlling the brightness of an LED with slide potentiometer:** A slide potentiometer is connected to an analog pin from which the value is taken to change the brightness of an LED connected to a PWM (Pulse Width Modulation) pin. \n - **analogRead()** is a function that can read analog values from the analog pins A0, A1, A2, A3, A4, and A5. Such pins get the values in integer forms, ranging from 0 to 1023.\n - **analgWrite()** writes an analog value in the pins denoted by ~ on the board. For Arduino uno, these pins are: 3, 5, 6, 9, 10, and 11. The analog value is created by PWM. To be more specific, the duty cycle of a rectangular wave is changed based on the desired analog value.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/376216892255611905\" \u003eLED Brightness change with slide potentiometer: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/3.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n4. **Playing a frequency on speaker with pushbutton:** A pushbutton is used to play a frequency on the speaker. By pressing or press-and-holding the pushbutton, the speaker gets a square wave, which we can hear it.\n - **tone(pin,frequency) or tone(pin,frequency,duration)** is a function that creates a square wave having 50% duty cycle with the specified frequency in Hertz. If duration (in milliseconds) is given, it generates the square wave for the given duration.\n - **noTone(pin)** stops the frequency generation on the given pin.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/376316961305570305\" \u003eGenerating sound with given frequency by pressing pushbutton: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/4.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n5. **By sliding the potentiometer, the angle of servo motor is changed:** A slide potentiometer is connected to arduino via an analog pin. Also a servo motor signal pin is connected to a PWM pin of arduino. We use the Servo library to control the angle of servo motor by sliding the potentiometer.\n - **Servo myservo** is employed to create an object of Servo from Servo library, here named *myservo*.\n - **myservo.attach(servo_pin)** attaches the servo motor with the specified pin, *servo_pin*, to the Servo object.\n - **myservo.write(angle)** sets the angle of servo motor to the specified angle.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/376507175360773121\" \u003eSetting servo motor angle by a slide potentiometer: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/5.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n6. **Displaying text on LCD:** An LCD is connected to arduino-uno via the data format 4-bit, which means only 4-bit are used for data transfer. We connect d4-d7 to pins of arduni for data transfer. Also, E(Enable) and RS (Register Select) pins are connected to arduino.\n - We use **LiquidCrystal** library for working with LCD. An lcd object is created using this library, which we name it *lcd*.\n - **lcd.begin(16,2)** declares that the lcd has 16 characters in each row, and it has two rows.\n - **lcd.setCursor(col,row)** sets the cursor at the given position.\n - **lcd.print(text)** types the given text on the LCD.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/376952093387792385\" \u003eDisplaying text on the LCD: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/6.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n7. **Typing characters on LCD with keypad:** A keypad is connected to arduino along an LCD. The keypad here has eight pins, four rows and four columns. \n - For the LCD, We use **LiquidCrystal** library as explained in previous post.\n - For the keypad, we use **Keypad** library, and thus creating a **Keypad object**,named *keypad* from this library.\n - By using **keypad.getKey()** we get the key that has been pressed.\n - Like previous post, we use **lcd.print(key)** to type the pressed key on the LCD.\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/377394615913614337\" \u003eTyping characters on LCD with keypad: click to see the live demo., and get the code\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/7.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e\n\n8. **Distance measurement with ultrasonic range finder:** An ultrasonic range finder is connected to the arduino. This range finder sends sound to the front and listens for the echo of the sound. To show the measured distance, we use an LCD, which is also connected to the arduino. \n - AS previous post, for the LCD, **LiquidCrystal** library is employed.\n - The trigger pin of the URF (Ultrasonic range finder) is set from LOW to HIGH for at least 10 microseconds to start the distance measurement.\n - By using **pulseIn(echo_pin,HIGH)**, we measure the time that a HIGH pulse is detected in the pin echo_pin until this pulse goes to LOW. This measured time is twice the the time for the sound wave to hit the obstacle.\n \u003cp align=\"center\"\u003e\n\u003ca href=\"https://wokwi.com/projects/377940164197559297\" \u003eDistance measurement with ultrasonic range finder\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"./Media/8.jpg\" width=\"500\" height=\"400\"/\u003e\n\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fostad-ai%2Farduino-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fostad-ai%2Farduino-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fostad-ai%2Farduino-tutorial/lists"}