{"id":26151718,"url":"https://github.com/hacksu/getting-started-with-arduino","last_synced_at":"2026-02-01T11:35:13.154Z","repository":{"id":280518236,"uuid":"942268730","full_name":"hacksu/Getting-Started-With-Arduino","owner":"hacksu","description":"This is a demo for Arduino created by Ian Rohrbacher for HacKSU at Kent State University","archived":false,"fork":false,"pushed_at":"2025-03-04T19:30:27.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T12:46:28.957Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/hacksu.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,"zenodo":null}},"created_at":"2025-03-03T20:59:39.000Z","updated_at":"2025-03-04T19:30:31.000Z","dependencies_parsed_at":"2025-06-07T22:15:34.533Z","dependency_job_id":null,"html_url":"https://github.com/hacksu/Getting-Started-With-Arduino","commit_stats":null,"previous_names":["hacksu/getting-started-with-arduino"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hacksu/Getting-Started-With-Arduino","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2FGetting-Started-With-Arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2FGetting-Started-With-Arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2FGetting-Started-With-Arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2FGetting-Started-With-Arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacksu","download_url":"https://codeload.github.com/hacksu/Getting-Started-With-Arduino/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacksu%2FGetting-Started-With-Arduino/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28977320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T11:31:13.034Z","status":"ssl_error","status_checked_at":"2026-02-01T11:30:25.558Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-03-11T06:39:01.982Z","updated_at":"2026-02-01T11:35:13.109Z","avatar_url":"https://github.com/hacksu.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Contents\n\u003e This is a demo created by Ian Rohrbacher for HacKSU at Kent State University\n\n* [Gettting Started](#gettting-started)\n* [Digital Signals](#digital-signals)\n  * [Input](#input)\n  * [Output](#output)\n* [Analog Signals](#analog-signals)\n  * [Input](#input-1)\n  * [Output](#output-1)\n* [Components](#components)\n  * [Servos](#servos)\n  * [Display](#display)\n\n# Lessons on Arduino\nArduino is an open-source electronics platform that makes it easy to create interactive projects. In the Arduino IDE, you can control LEDs, motors, and sensors using C++, *with just a few tiny differences*. It's widely used for prototyping and robotics, making it a great tool for anyone to use.\n\u003cbr\u003e\u003cbr\u003e\nThe following is an introduction to the basic skills you will need to know to get started. We will place less emphasis on electrical wiring and more on hardware and software.\n\n# Gettting Started\nWe will use [wokwi](https://wokwi.com/) for simulation. We will be using the [ESP32](https://wokwi.com/esp32) environment. The ESP32 is currently one of the best microcontrollers you can work with. Again we won't dive into the electrical aspect of the ESP32, but it is important to know the [pinout sheet](images/ESP32-Pinout.png) of the board. This will tell you what the numbers for your pins are and what the pins can do. We don't have to worry too much however because most of the pins are PWM allowing easy conversion from analog to digital.\n\n# New Project\nAfter selecting the ESP32 simulator, scroll down until you find 'Starter Templates' and select 'ESP32'. Welcome to your first project! Here you will see a few essentials; 'setup()', 'loop()', 'Serial', 'delay()'.\n```ino\nvoid setup() {\n  // put your setup code here, to run once:\n  Serial.begin(115200); // starts a serial connection\n  while(!Serial){} // wait until Serial is created\n  Serial.println(\"Hello, ESP32!\"); // prints to the serial\n}\n\nvoid loop() {\n  // put your main code here, to run repeatedly:\n  delay(10); // this speeds up execution time\n}\n```\n* setup(): Runs once at the beginning or on startup. Here, we will define important variables like defining pins and starting serial communication.\n* loop(): Runs continuously while active. Here is where all executing logic goes.\n* Serial: Used as an output stream.\n\u003e [!IMPORTANT] \n\u003e Always check your microcontroller for which port number to use, standard is 9600 however the simulator uses 115200. \n* delay(): This is your 'wait' statement. This is used to limit the amount of cycles the 'loop()' will make to ensure memory isn't being wasted.\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n# Digital Signals\nA digital signal is a type of signal that has only two discrete states: HIGH (1) or LOW (0). In Arduino, digital signals are used to communicate with components like LEDs, buttons, motors, and sensors, *however with limited control.*\n![digital](images/digital.png)\n\u003cbr\u003e\u003cbr\u003e\n\n## Output\nTo start, open the diagram.json file in the simulator and copy [this JSON](digital/write-one.json). You should see a circuit with an LED. Let's learn how to control this LED.\n\u003cbr\u003e\nLet's first define a variable for the pin, it is currently connected to pin 19.\n```ino\nint pin = 19;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n}\n\nvoid loop() {\n  delay(10);\n}\n```\nNext, we need to let the microcontroller, *ESP32*, know how to handle this pin. We can use pinMode with the parameter of the pin and OUTPUT telling it we will be outputting through this pin.\n```ino\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  pinMode(pin, OUTPUT);\n}\n```\nNow we can give the pin a state. To do this we can use digitalWrite with the parameter of the pin and the current state we want the LED to be in. For digital output, we can only use HIGH and LOW.\n```ino\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  pinMode(pin, OUTPUT);\n  digitalWrite(pin, HIGH);\n}\n```\nNow that we know how to use the LED let us add some basic logic into the loop() to toggle the LED on and off after some time.\n```ino\nint pin = 19;\nbool toggle = false;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  pinMode(pin, OUTPUT);\n}\n\n\nvoid loop() {\n  digitalWrite(pin, toggle ? HIGH : LOW);\n\n  Serial.println(toggle);\n  toggle = !toggle;\n  \n  delay(1500);\n}\n```\n\n## Input\nNow that we know how to change the LED in the code, let's add a button to control it instead. Open the diagram.json file in the simulator and copy [this JSON](digital/read-one.json). You should see the circuit with an LED now with a button.\n\u003cbr\u003e\nLet us redefine the LED pin and add a button pin that is connected to pin 14. Let us also set the pinMode to the button to INPUT so we can read the state.\n```ino\nint LED_pin = 19;\nint Button_pin = 14;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  pinMode(LED_pin, OUTPUT);\n  pinMode(Button_pin, INPUT);\n}\n```\nTo read from the button we use digitalRead. This will return the state of the button, HIGH or LOW. Now let us modify our logic from before and have digitalRead cast to a boolean.\n```ino\nvoid loop() {\n  bool pressed = digitalRead(Button_pin);\n  digitalWrite(LED_pin, pressed ? HIGH : LOW);\n\n  Serial.println(pressed);\n  \n  delay(100);\n}\n```\nAs you can see the digitalRead and digitalWrite are now inside the loop() allowing it to update every tick, defined by the delay.\n\u003cbr\u003e\nIf you ran this you might have noticed something, the button inconsistently updates the LED. This is due to the microcontroller flowing unsteady electricity through the button. We can fix this by changing the INPUT to INPUT_PULLUP which will ensure a HIGH stream of electricity to flow.\n```ino\n  pinMode(Button_pin, INPUT_PULLUP);\n```\n\n### For Fun\nI have created a model that uses three LEDs that change one after another [here is the JSON](digital/digital-three.json).\n```ino\nint pinR = 18;\nint pinG = 5;\nint pinB = 17;\nint pinList[] = {pinR, pinG, pinB};\nint state = 0;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  for(int pins : pinList) {\n    pinMode(pins, OUTPUT);  // Use a valid GPIO number\n  }\n}\n\n\nvoid loop() {\n  digitalWrite(pinR, state==0 ? HIGH : LOW);\n  digitalWrite(pinG, state==1 ? HIGH : LOW);\n  digitalWrite(pinB, state==2 ? HIGH : LOW);\n\n  Serial.println(state);\n  state = (state == 2 ? 0 : state+1);\n  \n  delay(1500);\n}\n```\n\n\n\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n# Analog Signals\nAn analog signal is a continuous signal that varies over time and can take any value within a given range. Unlike digital signals that are either HIGH (1) or LOW (0), analog signals can have infinite possible values. Analog signals are able to use the same components as digital; LEDs, buttons, motors, and sensors, however with finer control.\n![analog](images/analog.png)\n\u003cbr\u003e\u003cbr\u003e\n\n## Output\nWe will start once again with editing the diagram.json file. We will reuse the digital output diagram, however with a purple LED [JSON](analog/write-one.json). \n\u003cbr\u003e\nWe will make a small modification from the digital output code.\n```ino\nint pin = 19;\nint value = 0;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  pinMode(pin, OUTPUT);\n}\n\nvoid loop() {\n  value = value\u003e255 ? 0 : value+10;\n  analogWrite(pin, value);\n  Serial.println(value);\n\n  delay(500);\n}\n```\nNow instead of the LED turing on and off, it slowly climbs in brightness and resets after passing 255. 0-255 is the range of analogWrite which is why it will reset after 255.\n\n## Input\nNow that we saw the LED changing brightness, let's see how we can manually alter it. Open the diagram.json file in the simulator and copy [this JSON](analog/read-one.json). You should see the circuit we had befor with the potentiometer.\n\u003cbr\u003e\nSimilarly to the button, a potentiometer gives us a input. Unlike a button, where it has two states, a potentiometer has infinitely many states. For a ESP32 this is measure as a range from 0-4095. If we wanted to change that range for the LED to work properly, we can use a built in function 'map'. map allows us to alter any range as another, for our case 0-4095 to 0-255.\n```ino\nint pot = 14;\nint LED = 19;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n  \n  pinMode(pot, INPUT);\n  pinMode(LED, OUTPUT);\n}\n\nvoid loop() {\n  int value = map(analogRead(pot), 0, 4095, 0, 255);\n  analogWrite(LED, value);\n  \n  Serial.println(value);\n  delay(100);\n}\n```\nIf you are using map make sure you know the range of the orignal input, as having a difference can lead to unreliable outputs.\n\n### For Fun\nI have created an array of LEDs in the RGB colors along with a RGB LED. Potentiometers come in all styles too, so here I am using a nob. Each nob controls the brightness of their respective RGB colors and by mixing them you can see how the RGB LED reacts. [Here is the JSON](analog/analog-RGB.json)\n```ino\nint RPin = 19;\nint GPin = 18;\nint BPin = 5;\nint ponRPin = 26;\nint ponGPin = 27;\nint ponBPin = 14;\n\nvoid anode(int R, int G, int B) {\n  analogWrite(RPin, map(R, 0, 4095, 0, 255));\n  analogWrite(GPin, map(G, 0, 4095, 0, 255));\n  analogWrite(BPin, map(B, 0, 4095, 0, 255));\n}\n\nvoid printRGB(int R, int G, int B) {\n  Serial.println(\"-------------------------------\");\n  Serial.println(\"R:\"+String(map(R, 0, 4095, 0, 255)));\n  Serial.println(\"G:\"+String(map(G, 0, 4095, 0, 255)));\n  Serial.println(\"B:\"+String(map(B, 0, 4095, 0, 255)));\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n\n  pinMode(ponRPin, INPUT);\n  pinMode(ponGPin, INPUT);\n  pinMode(ponBPin, INPUT);\n\n  pinMode(RPin, OUTPUT);\n  pinMode(GPin, OUTPUT);\n  pinMode(BPin, OUTPUT);\n}\n\nvoid loop() {\n  int red = analogRead(ponRPin);\n  int green = analogRead(ponGPin);\n  int blue = analogRead(ponBPin);\n\n  anode(red, green, blue);\n  printRGB(red, green, blue);\n\n  delay(100);\n}\n```\n\n# Components\nArduino can interface with various external components like sensors, motors, displays, and more. These components communicate through different methods such as digital I/O, analog inputs, PWM, I2C, SPI, and UART. You can see on the [pinout sheet](images/ESP32-Pinout.png) of the ESP32 how the pins are defined. We will go over servos and one display board.\n\n\n\n## Servos\nServos are a type of motor that allows for precise control of angular position, speed, and torque. The unique thing about servos is that they can hold a position rather than continuously rotating.\n\u003cbr\u003e\nUsing our knowledge of analog inputs, we will read from a potentiometer to move a servo. lets use the new [diagram here](servo/servo-one.json) and this code as a start.\n```ino\nint pot = 14;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n  \n  pinMode(pot, INPUT);\n}\n\nvoid loop() {\n  int value = analogRead(pot);\n  \n  Serial.println(value);\n  delay(100);\n}\n```\n\nIn Arduino, a servo is its own class. To use this class we need to import ESP32Servo.h, open the 'Library Manager' and add 'ESP32Servo'. Next in the code, we need to include ESP32Servo.h. Now we can create a servo object and give it a pin to read from.\n```ino\n#include \u003cESP32Servo.h\u003e\n\nint pot = 14;\nconst int servoPin = 5;\n\nServo servo;\n\nvoid setup() {\n  Serial.begin(115200);\n  while(!Serial){}\n  Serial.println(\"Hello, ESP32!\");\n  \n  pinMode(pot, INPUT);\n  servo.attach(servoPin);\n}\n```\n\nThis servo can only hold 0-180 degrees so we will use a map to change the output of the potentiometer to match. Writing to the servo is easy, just call the write method from the object passing the potentiometer's changed value.\n```ino\nvoid loop() {\n  int value = map(analogRead(pot), 0, 4095, 0, 180);\n  servo.write(value);\n  \n  Serial.println(value);\n  delay(100);\n}\n```\n\nThere you have it, now you can change the position of the servo using the potentiometer as input.\n\n## Display\nWe have been using the serial ports to read data. And if you remember, you need the microcontroller to be plugged into your computer to read that data. Now what if we didn't want to be plugged in? This is where onboard displays come in.\n\u003cbr\u003e\nJust like servos, we need to import the library 'Adafruit SSD1306'. Unlike the servo, it matters which pins you use. We need to look at both the [ESP32](images/ESP32-Pinout.png) and the [OLED display](images/I2C-OLED-Display-Pinout.png) pinout sheet. We need to match the SCL and SDA pins. There are pin 22 and pin 21 respectively. The full diagram can be found [here](display/display-one.json)\n\u003cbr\u003e\nJust like the servo, we need to include Adafruit_SSD1306.h. Next, create an Adafruit_SSD1306 object with the parameters screen width and screen height. In setup, we start the display, apply styles, and clear the display.\n```ino\n#include \u003cAdafruit_SSD1306.h\u003e\n\nAdafruit_SSD1306 display(128, 64);\n\nvoid setup() {\n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);\n  display.setTextColor(WHITE);\n  display.setTextSize(1);\n  display.clearDisplay();\n}\n```\n\nTo use the display there are many functions in the Adafruit_SSD1306 class, but we will focus on text. To choose the origin of the text we can move it using setCursor and print to the screen wex use .print() like any other print method. The last thing you need to do is call .display(). The OLED display does not update automatically when you draw text or shapes. Instead, you are writing to a buffer inside the microcontroller. The function .display() sends the buffer contents to the actual screen.\n\n```ino\nvoid setup() {\n  ...\n\n  display.setCursor(0,5);\n  display.print(\"Hello World!\");\n  display.display();\n}\n```\n\n### For Fun\nUsing the slide potentiometer as an input, I have made it print custom text depending on how much the potentiometer has moved. [Diagram here](display/display-many.json)\n\n```ino\n#include \u003cAdafruit_SSD1306.h\u003e\n\nAdafruit_SSD1306 display(128, 64);\n\nint pot = 14;\n\nvoid printSwitch();\n\nvoid setup() {\n  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);\n  display.setTextColor(WHITE);\n  display.setTextSize(1);\n  display.clearDisplay();\n  \n  pinMode(pot, INPUT);\n}\n\nvoid loop() {\n  printSwitch(map(analogRead(pot), 0, 4095, 0, 5));\n\n  delay(100);\n}\n\nvoid printSwitch(int value) {\n  display.clearDisplay();\n  display.setCursor(0,15);\n\n  switch(value) {\n    case 0:\n      display.print(\"I love switches\");\n      break;\n\n    case 1:\n      display.print(\"Who needs ifs\");\n      break;\n\n    case 2:\n      display.print(\"FRC \u003e Vex\");\n      break;\n\n    case 3:\n      display.print(\"IDK... Something\");\n      break;\n\n    case 4:\n      display.print(\"Thanks for watching\");\n      break;\n\n    case 5:\n      display.print(\"This is the end\");\n      break;\n\n  }\n\n  display.display();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacksu%2Fgetting-started-with-arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacksu%2Fgetting-started-with-arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacksu%2Fgetting-started-with-arduino/lists"}