Home
ProgramLanguage
DataBase
Err Window Line MEGA SEO IDE Media Google UnixTimestamp Virus
Office
OperatingSystem
MultimediaDesign
Adobe
Photoshop
Illustrator
Corel
DRAW
Painter
PaintShop
會聲會影
Pinta
GIMP
Krita Desktop
Inkscape
Arduino
http://coopermaa2nd.blogspot.tw/2013_09_01_archive.html

藍芽
蜂鳴器
網路
觸控顯示屏
LED
LCD
LCDKPad
SDCard
SG90
Stepper步進馬達
Language

UNO
DUE
2560 
W5100






Arduino IDE 執行時,處理續是 javaw.exe *32

測試八路繼電器開關1
void setup() {
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(6, LOW);   // turn the LED off by making the voltage LOW
  delay(500);                  // wait for a second
  digitalWrite(6, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                  // wait for a second
  digitalWrite(7, LOW);
  delay(500);
  digitalWrite(7, HIGH);
  delay(500);
  digitalWrite(8, LOW);
  delay(500);
  digitalWrite(8, HIGH);
  delay(500);
  digitalWrite(9, LOW);
  delay(500);
  digitalWrite(9, HIGH);
  delay(500);
  digitalWrite(10, LOW);
  delay(500);
  digitalWrite(10, HIGH);
  delay(500);
  digitalWrite(11, LOW);
  delay(500);
  digitalWrite(11, HIGH);
  delay(500);
  digitalWrite(12, LOW);
  delay(500);
  digitalWrite(12, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
  digitalWrite(13, HIGH);
  delay(500);
}

or

void loop() {
  digitalWrite(6, LOW);   // turn the LED off by making the voltage LOW
  digitalWrite(6, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(500);                  // wait for a second
  digitalWrite(7, LOW);
  digitalWrite(7, HIGH);
  delay(500);
  digitalWrite(8, LOW);
  digitalWrite(8, HIGH);
  delay(500);
  digitalWrite(9, LOW);
  digitalWrite(9, HIGH);
  delay(500);
  digitalWrite(10, LOW);
  digitalWrite(10, HIGH);
  delay(500);
  digitalWrite(11, LOW);
  digitalWrite(11, HIGH);
  delay(500);
  digitalWrite(12, LOW);
  digitalWrite(12, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  digitalWrite(13, HIGH);
  delay(500);
}









滾珠開關搭配LCD監測震動時間


/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include 

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
  
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
  Serial.println(digitalRead(2));
  int timer;
  if(digitalRead(2) == HIGH){
    timer = timer + millis();
  //  Serial.println(timer);
  }
  
}







//從監控視窗可以看出 0 跟 1 的變化
void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
}

void loop() {
  Serial.println(digitalRead(2));
}





//比上面的多出了 LED 燈的控制
void setup() {
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(2, INPUT);
}

void loop() {
  Serial.println(digitalRead(2));
  if(digitalRead(2)==HIGH){
    digitalWrite(13, HIGH);
    delay(1000);	//註記這行晃動開關時,LED 燈的閃滅會很快速
  }else{
    digitalWrite(13, LOW);
  }
}

http://jprogramar.blogspot.tw/2014/07/how-to-work-with-hdx2-vibration-switch.html



//利用 millis() 











// include the library code:
#include 

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);
  lcd.begin(16, 2);
  lcd.print("Hello!");
  
}

void loop() {
  int HIGHTimer;
  int LOWTimer;
  int SensorStatus;
  int OldSensorStatus;
  int HIGHTag;
  int LOWTag;
  int SensorStatusCount;
  SensorStatus = digitalRead(2);
  lcd.setCursor(0, 1);
  if(SensorStatus == HIGH){
    digitalWrite(13, LOW);
    HIGHTimer = millis()/1000;
  }else{
    digitalWrite(13, HIGH);
    LOWTimer = millis()/1000;
  }
  if(SensorStatus != OldSensorStatus){
    if(HIGHTimer > LOWTimer){
      HIGHTag = HIGHTag + (HIGHTimer - LOWTimer);
    }else{
      LOWTag = LOWTag + (LOWTimer - HIGHTimer);
    }
  }
  OldSensorStatus = SensorStatus;
  //lcd.print(HIGHTag);
  //lcd.print(LOWTag);
  Serial.println(HIGHTag);
}














// include the library code:
#include 

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

  int RunTime;
  int RunTimeStatus;
  int CatchStatus;
  int CatchTime;
  int SensorStatus;
  int OldSensorStatus;
  int SensorStatusCount;

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);
  lcd.begin(16, 2);
}

void loop() {
  SensorStatus = digitalRead(2);
  //如果狀態相同開始計數,不同計數歸零
  if(SensorStatus == OldSensorStatus){
    //是要抓看是不是停止了
    SensorStatusCount = SensorStatusCount + 1;
  }else{
    SensorStatusCount = 0;
  }
  //如果計數超過 50
  if(SensorStatusCount > 50){
    if(RunTimeStatus){
        if((millis() - CatchTime) > 500){
          RunTime = RunTime + (millis() - CatchTime);
        }
        RunTimeStatus=false;
    }
    CatchStatus = true;
  }else{
    if(CatchStatus){
      //取得變動一開始的時間
      CatchTime = millis();
      RunTimeStatus = true;
      CatchStatus = false;
    }
  }
  if(SensorStatus == HIGH){
    digitalWrite(13, HIGH);
  }else{
    digitalWrite(13, LOW);
  }
  OldSensorStatus = SensorStatus;
  lcd.clear();
  lcd.setCursor(0, 0);//設定游標位置
  lcd.print("Hello!");
  lcd.setCursor(0, 1);//設定游標位置
  //lcd.cursor(); // 顯示游標(底線)
  //lcd.noCursor(); // 不顯示游標(底線)
  //lcd.blink(); // 讓游標閃爍
  //lcd.noBlink(); // 讓游標不閃爍
  //lcd.autoscroll(); //自動捲動
  //lcd.leftToRight(); //捲動方向
  //lcd.rightToLeft(); //捲動方向
  //lcd.scrollDisplayLeft(); //
  //lcd.scrollDisplayRight(); //
  lcd.print(RunTime/1000);
  //Serial.print(SensorStatus);
  //Serial.print("-");
  //Serial.print(OldSensorStatus);
  //Serial.print("-");
  Serial.println(RunTime);
}










Examples


•Autoscroll: Shift text right and left.
•Blink: Control of the block-style cursor.
•Cursor: Control of the underscore-style cursor.
•Display: Quickly blank the display without losing what's on it.
•Hello World: Displays "hello world!" and the seconds since reset.
•Scroll: Scroll text left and right.
•Serial Display: Accepts serial input, displays it.
•Set Cursor: Set the cursor position.
•Text Direction: Control which way text flows from the cursor.



https://www.arduino.cc/en/Reference/LiquidCrystal




































Arduino
Arduino




Simulator For Arduino

Using Simulator For Arduino IDE on Windows

Arduino Builder
Using Arduino Builder Arduino IDE on Windows

CodeBlocks
Using CodeBlocks Arduino IDE on Windows

Using CodeBlocks Arduino IDE on Linux

ArduinoDebugger
ArduinoDebugger

Simduino Simduino Simduino Emulare Emulare Fritzing Fritzing http://www.virtualbreadboard.com/ PCBWeb Designer http://www.pcbweb.com/ ZenitPCB http://www.zenitpcb.com/ TinyCAD http://sourceforge.net/projects/tinycad/files/latest/download Osmond PCB http://www.osmondpcb.com/index.html BSch3V http://www.suigyodo.com/online/e/index.htm ExpressPCB http://www.electroschematics.com/832/expresspcb-download/ Kicad http://kicad-pcb.org/ gEDA http://www.gpleda.org/ DesignSpark PCB http://www.designspark.com/eng/page/designspark-pcb-home-page EasyEDA https://easyeda.com/ 標準函式庫 AudrinoTestSuite EEPROM SD Ethernet Firmata LiquidCrystal Servo(伺服馬達) Stepper(步進馬達) SPI Wire SoftwareSerial https://www.arduino.cc/en/Main/Software 水溫、酸鹼值(pH)、氧化還原值(ORP)、電導度(EC)、溶氧量(DO)、濁度(SS)
| 關於我們 | 聯絡我們 | 更新記錄 |
版權所有 轉載必究 服務專線: