“Lighten Led”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
Pkj讨论 | 贡献
(Created page with "{{Language | 点亮led灯}} {| style="width: 800px;" |- | ==Objective== This tutorial will teach you how to use the Processing to light LED. ==Equipment== *'''Microduino-Co...")
 
(没有差异)

2014年5月27日 (二) 07:59的最新版本

Language English

Objective

This tutorial will teach you how to use the Processing to light LED.

Equipment

  • Other equipment
    • USB cable one
    • LED one
    • 330Ω resistor one
    • Bread one
    • Breadboard Jumper onebox

Schematic

ProcessingControlLED原理图.jpg

Program

https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/LEDButtonByOver

https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/LEDButtonByClick

Note:Don't drop the picture in program

Debut

Step 1:Set up hardware system, as follows:

ProcessingControlLED连接图.jpg

Step 2:Explain the code:

// Declaring two variable of type PImage, a class available to us from the Processing core library. PImage LEDON, LEDOFF;

//load two img LEDON = loadImage("LEDON.png"); LEDOFF = loadImage("LEDOFF.png");

Mouse movement will light the LED which was realized in LEDButtonByOver.

Mouse over:

 // When the mouse is moved, the state of the button is toggled. 
 void mouseMoved() {
   if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) {
     button = true;
   }  
   else {
     button = false;
   }
 }

Mouse click will light the LED which was realized in LEDButtonByClick.

Mouse Click:

 // When the mouse is pressed, the state of the button is toggled.   
 void mousePressed() {
   if (mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h) {
     button = !button;
   }  
 }

Step 3:Compile the code and download it.


Step 4:After run, mouse move or click the LED, observe the result.

Result

Mouse move on the LED, it will light, and trun off when leave it. Processing'S animation effects:

ProcessingOverLEDON.jpg
ProcessingOverLEDOFF.jpg

Video