步骤从C / C ++程序进行LED闪烁? [英] Steps to make a LED blink from a C/C++ program?

查看:239
本文介绍了步骤从C / C ++程序进行LED闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是做一个小电路从C / C ++程序LED闪光灯?最简单的步骤

What are the easiest steps to make a small circuit with an LED flash from a C/C++ program?

我想preFER所需的依赖和包数最少的。

I would prefer the least number of dependencies and packages needed.


  • 什么端口将我连接到的东西?

  • 哪些编译器怎么用?

  • 如何将数据发送到该端口?

  • 请我需要有一个微型处理器?如果不是我不想用一个这个简单的项目。

编辑:感兴趣的任何操作系统的具体解决方案。

Interested in any OS specific solutions.

推荐答案

下面是上一个的并口

虽然我会建议一个 Arduino的可以非常便宜购买,将只涉及以下code:

Though I would recommend an Arduino which can be purchased very cheaply and would only involve the following code:

/* Blinking LED
 * ------------
 *
 * turns on and off a light emitting diode(LED) connected to a digital  
 * pin, in intervals of 2 seconds. Ideally we use pin 13 on the Arduino 
 * board because it has a resistor attached to it, needing only an LED

 * 
 * Created 1 June 2005
 * copyleft 2005 DojoDave <http://www.0j0.org>
 * http://arduino.berlios.de
 *
 * based on an orginal by H. Barragan for the Wiring i/o board
 */

int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

<一个href=\"http://www.arduino.cc/en/Tutorial/BlinkingLED\">http://www.arduino.cc/en/Tutorial/BlinkingLED

这篇关于步骤从C / C ++程序进行LED闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆