π 곡λΆνλ μ§μ§μνμΉ΄λ μ²μμ΄μ§?
[UNO R4 WIFI example] Digital-to-Analog Converter (DAC) λ³Έλ¬Έ
π©π» IoT (Embedded)/Arduino
[UNO R4 WIFI example] Digital-to-Analog Converter (DAC)
μ§μ§μνμΉ΄ 2023. 11. 28. 17:04728x90
λ°μν
< λ³Έ λΈλ‘κ·Έλ ARDUINO docs μ μ°Έκ³ ν΄μ 곡λΆνλ©° μμ±νμμ΅λλ€ :-) >
β Digital-to-Analog Converter (DAC)
π³ CODE
/*
SineWave
Generates a pre-generated sawtooth-waveform.
See the full documentation here:
https://docs.arduino.cc/tutorials/uno-r4-wifi/dac
*/
#include "analogWave.h" // Include the library for analog waveform generation
// DACμμ μ¬μΈν λ°μ§μ΄ μμ±λκΈ° μμ
// μ£Όνμμ λ°λΌ μμ λ²μ λ μ€νΌμ»€μμ μ¬μ΄λλ₯Ό μμ±νλ λ° μ¬μ©
analogWave wave(DAC); // Create an instance of the analogWave class, using the DAC pin
int freq = 10; // in hertz, change accordingly
void setup() {
Serial.begin(115200); // Initialize serial communication at a baud rate of 115200
// μκ°μ λ°λ₯Έ μ μμ κ·Έλνλ‘ κ·Έλ¦¬λ©΄ μ μ΄ μ¬μΈ ν¨μμ²λΌ 보μ΄κΈ° λλ¬Έμ μ΄λ₯Ό μ¬μΈν
//wave.sine(freq); // Generate a sine wave with the initial frequency
wave.saw(freq);
}
void loop() {
// Read an analog value from pin A5 and map it to a frequency range
freq = map(analogRead(A5), 0, 1024, 0, 10000);
// Print the updated frequency to the serial monitor
Serial.println("Frequency is now " + String(freq) + " hz");
wave.freq(freq); // Set the frequency of the waveform generator to the updated value
delay(1000); // Delay for one second before repeating
}
728x90
λ°μν
'π©βπ» IoT (Embedded) > Arduino' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
CAN (Controller Area Network) μ΄λ? with Arduino UNO R4 WIFI (0) | 2023.11.30 |
---|---|
μ€μκ°(Real Time) μ΄μ체μ (OS) μ RTOSμ FreeRTOS μ¬μ©ν΄λ³΄κΈ° (0) | 2023.11.29 |
[UNO R4 WIFI example] Real-Time ClockRTCAlarm (0) | 2023.11.28 |
[UNO R4 WIFI example] WiFi Web Server LED Blink (1) | 2023.11.28 |
[μλμ°¨ λ·νΈμ LCDνμΌλ‘ μν© μ λ¬νκΈ° 7] μμ±λ³Έ (0) | 2023.11.10 |
Comments