Arduino : 모스 번역사 구축-작동 방식
이 실용적인 팁에서는 Arduino로 모스 번역기를 쉽게 구축하는 방법을 배우게됩니다.
Arduino로 모스 번역기 제작하기-이것이 필요합니다
우선, 아두 이노가 필요합니다.
- 또한 활성화 된 버저와 LED가 있어야합니다.
- 버저를 핀 9에, LED를 핀 13에 연결합니다.
Arduino : 프로그램 모스 번역기
여기서는 작은 샘플 코드를 프로그래밍하여 사용할 수 있습니다. 간단히 Arduino에 업로드하고 직렬 모니터를 시작하십시오.
- #define debug true
- int ledPin = 13;
- int speakerPin = 9;
- int pitch1 = 140;
- int pitch2 = 140;
- 정수 도트 = 50;
- int dash = 3 * 도트;
- 문자열 morseATable [] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "-.", ". ... ", ".. ", ".--- ", "_._ ", ".- .. ", "- ", "-. ", "--- ", ".-- ", "--.- ", ".-. ", "... ", "- ", "..- ", "...- ", ".-- ", "-..- ", "-.-- ", "-.. "};
- 문자열 morseNTable [] = { "-----", ".----", "..---", "...--", "....-", "... .. ", "-.... ", "--... ", "--- .. ", "----. "};
- 무효 설정 () {
- pinMode (ledPin, OUTPUT);
- pinMode (스피커 핀, 출력);
- Serial.begin (9600);
- if (디버그) {
- Serial.println ( "\ n 다음");}
- }
- 무효 루프 () {
- if (true) {
- convert2Morse (Serial.readString ());
- }
- }
- void convert2Morse (문자열 메시지) {
- for (int pos = 0; pos <message.length (); pos ++) {
- if (디버그) {
- Serial.print (message.charAt (POS));
- Serial.print ( "");
- }
- if (((message.charAt (pos)> = 97) && (message.charAt (pos) <= 122)) {
- morseLED (morseATable [message.charAt (POS) -97])}
- if ((message.charAt (pos)> = 48) && (message.charAt (pos) <= 57)) {
- morseLED (모스 [표 메시지 [POS] -48])}
- if (message.charAt (pos) == 32) {
- morseLED ( "");}
- if (디버그) {
- Serial.println ();
- }
- }}
- void morseLED (문자열 순서) {
- for (int pos = 0; pos <sequence.length (); pos ++) {
- FlashLED (sequence.charAt (POS));}
- 지연 (2 * 도트);
- }
- void flashLED (char dotOrDash) {
- if (디버그) {
- Serial.print (dotOrDash)}
- if (dotOrDash == 46) {
- digitalWrite (ledPin, HIGH);
- 톤 (speakerPin, pitch1);
- 지연 (도트);
- digitalWrite (ledPin, LOW);
- noTone (speakerPin);
- 지연 (도트);
- } else if (dotOrDash == 45) {
- digitalWrite (ledPin, HIGH);
- 톤 (speakerPin, pitch2);
- 지연 (대시);
- digitalWrite (ledPin, LOW);
- noTone (speakerPin);
- 지연 (도트);
- } else if (dotOrDash == 32) {
- 지연 (도트)}
- }
다음 실용적인 팁에서는 Arduino에서 GSM 모듈을 사용하는 방법을 보여줍니다.