佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 743|回复: 0

Arduino 和 LED Display?

[复制链接]
发表于 24-3-2017 10:16 AM | 显示全部楼层 |阅读模式
本帖最后由 hinghui88 于 24-3-2017 11:53 AM 编辑

我本身刚刚认识了Arduino这东西,是从一位来公司做实习的外国实习生。
但是Project还没完成他因为私人的事离开了马来西亚。


现在,我只剩下一个Arduino和LED Display。


我请教了很多人,但是他们都没办法回答我的问题,希望这边的大神现身解答。

我有一个Arduino和他的Code。

const int SonarPin1 = A0;
const int SonarPin2 = A2;
const int SonarPin3 = A4;
const int SonarPin4 = A6;
const int SonarPin5 = A8;
const int SonarPin6 = A9;
const int SonarPin7 = A11;
const int SonarPin8 = A13;

#define txPin 14
#define rxPin 15

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
}

void loop()
{
  long duration, duration1, duration2, duration3, duration4, duration5, duration6, duration7, duration8;
  long parking = 8;

  // first sensor
  duration1 = analogRead(SonarPin1)/2;

  duration2 = analogRead(SonarPin2)/2;

  duration3 = analogRead(SonarPin3)/2;

  duration4 = analogRead(SonarPin4)/2;

  duration5 = analogRead(SonarPin5)/2;

  duration6 = analogRead(SonarPin6)/2;

  duration7 = analogRead(SonarPin7)/2;

  duration8 = analogRead(SonarPin8)/2;


  if(duration1 < 8)
    parking--;

  if(duration2 < 8)
    parking--;

  if(duration3 < 8)
    parking--;

  if(duration4 < 8)
    parking--;

  if(duration5 < 8)
    parking--;

  if(duration6 < 8)
    parking--;

  if(duration7 < 8)
    parking--;

  if(duration8 < 8)
    parking--;

  Serial.print("number of empty Spaces: ";
  Serial.print(parking);
  Serial.print("\n";



  delay(100);



}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}



和一个LED Display,我要怎样把Arduino收到的Information,寄出Serial Command去LED?

Supplier说:把"B101"放进去就行了...


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 15-12-2024 11:29 PM , Processed in 0.111647 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表