펄스 발생기를 만들수 있는 방법을 알려주십시요
듀티비는 50%이고, 가변 주파수는 1-500Hz 구형파가 나오는 회로를 설계하고 싶습니다.
오렌지보드 또는 확장 실드로 구현 방법이 있으면 알려주십시요.//
답신받은 데로 구현하여 타이머를 사용한 스케치 파일입니다.
500hz(2msec)에서 파형이 좌우로 진동하는데(오실로스코프로 측정) 이것을 잡을 수 있는 방법좀 알려주십시요
/* Blink without Delay
Turns on and off a light emitting diode (LED) connected to a digital
pin, without using the delay() function. This means that other code
can run at the same time without being interrupted by the LED code.
*/
const int led1Pin = 13; // the number of the LED pin
const int led2Pin = 12; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 2; // interval at which to blink (milliseconds)
void setup() {
pinMode(led1Pin, OUTPUT); // set the digital 13 pin as output:
pinMode(led2Pin, OUTPUT); // set the digital 12 pin as output:
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; // save the last time you blinked the LED
if (ledState == LOW) { // if the LED is off turn it on and vice-versa:
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(led1Pin, ledState); // set the LED with the ledState of the variable:
digitalWrite(led2Pin, ledState); // set the LED with the ledState of the variable:
}
}
|