Arduino Uno Цифровые контакты ввода-вывода
Download 1.39 Mb.
|
3-MAVZU
Arduino UnoЦифровые контакты ввода-выводаШиротно-импульсная модуляцияПервая программаЗадача:Необходимо заставить мигать светодиод, расположенный на плате.Этот светодиод подключен к цифровому контакту 13.Программа часть 1/*BlinkTurns on an LED on for one second, then off for one second, repeatedly.This example code is in the public domain.*/// Pin 13 has an LED connected on most Arduino boards.// give it a name:Часть 2int led = 13;// the setup routine runs once when you press reset:void setup() {// initialize the digital pin as an output.pinMode(led, OUTPUT);}Часть 3// the loop routine runs over and over again forever:void loop() {digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)delay(1000); // wait for a seconddigitalWrite(led, LOW); // turn the LED off by making the voltage LOWdelay(1000); // wait for a second}Подключение внешнего светодиодаКонфигурация контактовconst int LED=9; //define LED for pin 9void setup(){pinMode (LED, OUTPUT); //Set the LED pin as an outputdigitalWrite(LED, HIGH); //Set the LED pin high}void loop(){//we are not doing anything in the loop!}Изменение частоты мигания светодиодаconst int LED=9; //define LED for Pin 9void setup(){pinMode (LED, OUTPUT); //Set the LED pin as an output}void loop(){for (int i=100; i<=1000; i=i+100){digitalWrite(LED, HIGH);delay(i);digitalWrite(LED, LOW);delay(i);}}Download 1.39 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling