ғ Setup () қ. ү қ. ғ қғ ә .. ң қ. қ ә ғ , қ қ.
Arduino.
Example int buttonPin = 3;
void setup ()
{ Serial.begin (9600);
pinMode (buttonPin, INPUT); }
void loop ()
{ //... }
loop ()
setup () қғ ң, қ ғ loop () ә , ұ ң ғңғ ғ ү қ. Arduino қғ .
:
int buttonPin = 3;
// Setup initializes serial port and button
void setup ()
{
beginSerial (9600);
pinMode (buttonPin, INPUT);
}
// Cycle checked state of the button,
// And the serial port will be sent when it is pressed
void loop ()
{
if (digitalRead (buttonPin) == HIGH)
serialWrite ('H');
else
serialWrite ('L');
delay (1000);
}
Arduino ү қ ү ? ʳ қ ғ ?
ʳ қ қ, : құғ өң. ʳ қ ү, ә > ң.
ʳ : қ (extension.h) ә (with the extension.cpp) ү . ʳ қ қ құғ Morse.h . Ә қ ұ ү ү, өң ғ ұ қ.
ққ .
ұ ғ ғ . (public) ү ә ғ қ ғ қ , ұ (private). Ә құ ү ғ ң . , қ қ ү қ. -қққ қ қ . , ұ ү қ ү қ #include, ә ұқ . Arduino (ә ғ қ). ә ө:
|
|
#include "WProgram.h"
Full code: ʳң қ :
/* Morse.cpp - Library for flashing Morse code.
Created by David A. Mellis, November 2, 2007.
Released into the public domain. */
#include "WProgram.h"
#include "Morse.h"
Morse::Morse(int pin)
{ pinMode(pin, OUTPUT);
_pin = pin;}
void Morse::dot()
{ digitalWrite(_pin, HIGH);
delay(250);
digitalWrite(_pin, LOW);
delay(250); }
void Morse::dash()
{ digitalWrite(_pin, HIGH);
delay(1000);
digitalWrite(_pin, LOW);
delay(250); }
ʳ .
, қ Morse - қ ң қ. ң Notepad . , ө ү ә Morse.cpp Morse.h ү құғ қ. ғ Arduino ә Sketch> ImportLibrary Morse ұ . ʳ ү . ѳ , ң . ң.cpp ә.h (қ қ , ң.pde ә.txt). ғ әқ ң қ ү . ұ ә ү, Morse қ ң. ө құғ SOS қ құң. ( menyuSketch> ShowSketchFolder) қ ғ , Arduino ә > Sketchbook> ө, қ қ . ұ ү punktLibrary-Morse,. -қ ү қ .