Compare commits
2 Commits
fdf5ba2673
...
bb0c6fb8f5
Author | SHA1 | Date |
---|---|---|
Shwetha Jayaraj | bb0c6fb8f5 | |
Shwetha Jayaraj | fb3a36da8a |
|
@ -1,5 +1,21 @@
|
|||
{
|
||||
"recentFiles": [
|
||||
{
|
||||
"basename": "Arduino Examples",
|
||||
"path": "Arduino Examples.md"
|
||||
},
|
||||
{
|
||||
"basename": "Example Blink",
|
||||
"path": "Example Blink.md"
|
||||
},
|
||||
{
|
||||
"basename": "Analog SerialReader",
|
||||
"path": "Analog SerialReader.md"
|
||||
},
|
||||
{
|
||||
"basename": "Arduino",
|
||||
"path": "Machine Tips (Quantum)/Physics/Hardware/MicroControllers/Arduino.md"
|
||||
},
|
||||
{
|
||||
"basename": "Related Projects",
|
||||
"path": "Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/Related Projects.md"
|
||||
|
@ -183,22 +199,6 @@
|
|||
{
|
||||
"basename": "Progressive Web Apps",
|
||||
"path": "Coding Tips (Classical)/Terminal Tips/GUIs/Tools/Progressive Web Apps.md"
|
||||
},
|
||||
{
|
||||
"basename": "Please",
|
||||
"path": "Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Please.md"
|
||||
},
|
||||
{
|
||||
"basename": "GPU",
|
||||
"path": "GPU.md"
|
||||
},
|
||||
{
|
||||
"basename": "Fortran",
|
||||
"path": "Coding Tips (Classical)/Terminal Tips/Languages/Fortran.md"
|
||||
},
|
||||
{
|
||||
"basename": "fzf",
|
||||
"path": "fzf.md"
|
||||
}
|
||||
],
|
||||
"omittedPaths": [],
|
||||
|
|
|
@ -13,13 +13,50 @@
|
|||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/Related Projects.md",
|
||||
"file": "Machine Tips (Quantum)/Physics/Hardware/MicroControllers/Arduino.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "888f3d7d90adcfb4",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Analog SerialReader.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "ba2ee95c2aff766a",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Example Blink.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "9c6cff9d142839ae",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Arduino Examples.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 3,
|
||||
"stacked": true
|
||||
}
|
||||
],
|
||||
|
@ -94,7 +131,7 @@
|
|||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/Related Projects.md",
|
||||
"file": "Arduino Examples.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
|
@ -111,7 +148,7 @@
|
|||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/Related Projects.md",
|
||||
"file": "Arduino Examples.md",
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
}
|
||||
|
@ -134,7 +171,7 @@
|
|||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/Related Projects.md"
|
||||
"file": "Arduino Examples.md"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,10 +196,14 @@
|
|||
"command-palette:Open command palette": false
|
||||
}
|
||||
},
|
||||
"active": "012e39cfd1f0b5b6",
|
||||
"active": "9c6cff9d142839ae",
|
||||
"lastOpenFiles": [
|
||||
"Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/typewriter Keys.md",
|
||||
"Example Blink.md",
|
||||
"Arduino Examples.md",
|
||||
"Analog SerialReader.md",
|
||||
"Machine Tips (Quantum)/Physics/Hardware/MicroControllers/Arduino.md",
|
||||
"Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/Related Projects.md",
|
||||
"Coding Tips (Classical)/Project Vault/Communication Projects/Typewriter/typewriter Keys.md",
|
||||
"Machine Tips (Quantum)/NYU Haqathon.md",
|
||||
"Coding Tips (Classical)/Project Vault/Communication Projects/WRITTEN TEXT/E-Mail Templates.md",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Shwetha Jayaraj Notes.md",
|
||||
|
@ -196,10 +237,6 @@
|
|||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/QRG INK designs/images/Pasted image 20231002143635.png",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/QRG INK designs",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/hi.shwethajayaraj/Resume-ish - my occupations.md",
|
||||
"2023-10-02.md",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/hi.shwethajayaraj/Quantum Stuff.md",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/hi.shwethajayaraj/pdf.md",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/hi.shwethajayaraj/Main Page.md",
|
||||
"Coding Tips (Classical)/Project Vault/Current Occupations/Website Projects/hi.shwethajayaraj/Coding Projects.md"
|
||||
"2023-10-02.md"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
via [Arduino Example ](https://docs.arduino.cc/built-in-examples/basics/AnalogReadSerial)
|
||||
|
||||
Read a potentiometer, print its state out to the Arduino Serial Monitor.
|
||||
|
||||
LAST REVISION:09/19/2023, 10:55 AM
|
||||
|
||||
This example shows you how to read analog input from the physical world using a potentiometer. A **potentiometer** is a simple mechanical device that provides a varying amount of resistance when its shaft is turned. By passing voltage through a potentiometer and into an analog input on your board, it is possible to measure the amount of resistance produced by a potentiometer (or _pot_ for short) as an analog value. In this example you will monitor the state of your potentiometer after establishing serial communication between your Arduino and your computer running the Arduino Software (IDE).
|
||||
|
||||
### Hardware Required
|
||||
|
||||
- Arduino Board
|
||||
|
||||
- 10k ohm Potentiometer
|
||||
|
||||
|
||||
### Circuit
|
||||
|
||||
Connect the three wires from the potentiometer to your board. The first goes from one of the outer pins of the potentiometer to ground. The second goes from the other outer pin of the potentiometer to 5 volts. The third goes from the middle pin of the potentiometer to the analog pin A0.
|
||||
|
||||
[![circuit](https://docs.arduino.cc/static/10842b0499a5e4e370aedcd222b52e2c/a6d36/circuit.png "circuit")](https://docs.arduino.cc/static/10842b0499a5e4e370aedcd222b52e2c/5a190/circuit.png)
|
||||
|
||||
By turning the shaft of the potentiometer, you change the amount of resistance on either side of the wiper, which is connected to the center pin of the potentiometer. This changes the voltage at the center pin. When the resistance between the center and the side connected to 5 volts is close to zero (and the resistance on the other side is close to 10k ohm), the voltage at the center pin nears 5 volts. When the resistances are reversed, the voltage at the center pin nears 0 volts, or ground. This voltage is the _analog voltage_ that you're reading as an input.
|
||||
|
||||
The Arduino boards have a circuit inside called an _analog-to-digital converter or ADC_ that reads this changing voltage and converts it to a number between 0 and 1023. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is turned all the way in the opposite direction, there are 5 volts going to the pin and the input value is 1023. In between, [analogRead](https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/)() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.
|
||||
|
||||
### Schematic
|
||||
|
||||
[![schematic](https://docs.arduino.cc/static/3bb842ec08b8a83f88c1a7c32800fe41/a6d36/schematic.png "schematic")](https://docs.arduino.cc/static/3bb842ec08b8a83f88c1a7c32800fe41/5a190/schematic.png)
|
||||
|
||||
### Code
|
||||
|
||||
In the sketch below, the only thing that you do in the setup function is to begin serial communications, at 9600 bits of data per second, between your board and your computer with the command:
|
||||
|
||||
```
|
||||
Serial.begin(9600);
|
||||
```
|
||||
|
||||
Next, in the main loop of your code, you need to establish a variable to store the resistance value (which will be between 0 and 1023, perfect for an [](https://www.arduino.cc/reference/en/language/variables/data-types/int/)
|
||||
|
||||
[`int`](https://www.arduino.cc/reference/en/language/variables/data-types/int/)
|
||||
|
||||
[datatype](https://www.arduino.cc/reference/en/language/variables/data-types/int/)) coming in from your potentiometer:
|
||||
|
||||
```
|
||||
int sensorValue = analogRead(A0);
|
||||
```
|
||||
|
||||
Finally, you need to print this information to your serial monitor window. You can do this with the command [Serial.println](https://www.arduino.cc/en/Serial/Println)() in your last line of code:
|
||||
|
||||
```
|
||||
Serial.println(sensorValue);
|
||||
```
|
||||
|
||||
Now, when you open your Serial Monitor in the Arduino Software (IDE) (by clicking the icon that looks like a lens, on the right, in the green top bar or using the keyboard shortcut Ctrl+Shift+M), you should see a steady stream of numbers ranging from 0-1023, correlating to the position of the pot. As you turn your potentiometer, these numbers will respond almost instantly.
|
||||
|
||||
### Learn more
|
||||
|
||||
You can find more basic tutorials in the [built-in examples](https://docs.arduino.cc/built-in-examples) section.
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
Of potential use for typewriter project
|
||||
|
||||
- [Keyboard Reprogram ](https://docs.arduino.cc/built-in-examples/usb/KeyboardReprogram)
|
||||
- Analog Serial Reader
|
||||
- [Keyboard Serial ](https://www.arduino.cc/en/Tutorial/BuiltInExamples/AnalogReadSerial)
|
||||
-
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
Output
|
||||
|
||||
```
|
||||
/usr/local/bin/arduino-cli compile --fqbn arduino:renesas_uno:unor4wifi --build-cache-path /tmp --output-dir /tmp/1818557322/build --build-path /tmp/arduino-build-56F548E7166434CC179598B3A39A949B /tmp/1818557322/Blink
|
||||
|
||||
Sketch uses 51448 bytes (19%) of program storage space. Maximum is 262144 bytes.
|
||||
|
||||
Global variables use 6744 bytes (20%) of dynamic memory, leaving 26024 bytes for local variables. Maximum is 32768 bytes.
|
||||
```
|
Loading…
Reference in New Issue