Test3

From ArduinoInfo
Jump to navigation Jump to search
---( copy and paste from IDE )----
/* YourDuino Electronic Brick Test
Simple Switch type INPUT DEVICES
with Serial Monitor Output
terry@yourduino.com */

/*-----( Declare Constants )-----*/
#define SWITCHPIN 2
#define LEDPIN 13

/*-----( Declare Variables )-----*/
int switch_state; /* Holds the last state of the switch */

void setup() /*----( SETUP: RUNS ONCE )----*/
{
pinMode(LEDPIN, OUTPUT);
Serial.begin(9600);

}/*--(end setup )---*/


void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
Serial.print("SWITCH IS - ");
switch_state = digitalRead(SWITCHPIN);
if (switch_state == HIGH)
{
digitalWrite(LEDPIN, HIGH);
Serial.println("HIGH");
}
else
{
digitalWrite(LEDPIN, LOW);
Serial.println("LOW");
}
delay(250); /* Wait a bit to see display */
}/* --(end main loop )-- */

/* ( THE END ) */





---( copy for forum)-----

[quote]
[color=#7E7E7E]/* YourDuino Electronic Brick Test[/color]
[color=#7E7E7E] Simple Switch type INPUT DEVICES[/color]
[color=#7E7E7E] terry@yourduino.com */[/color]

[color=#7E7E7E]/*-----( Declare Constants )-----*/[/color]
#define SWITCHPIN 2
#define LEDPIN 13

[color=#7E7E7E]/*-----( Declare Variables )-----*/[/color]
[color=#CC6600]int[/color] switch_state; [color=#7E7E7E]/* Holds the last state of the switch */[/color]

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() [color=#7E7E7E]/*----( SETUP: RUNS ONCE )----*/[/color]
{
[color=#CC6600]pinMode[/color](LEDPIN, [color=#006699]OUTPUT[/color]);

}[color=#7E7E7E]/*--(end setup )---*/[/color]


[color=#CC6600]void[/color] [color=#CC6600]loop[/color]() [color=#7E7E7E]/*----( LOOP: RUNS CONSTANTLY )----*/[/color]
{

switch_state = [color=#CC6600]digitalRead[/color](SWITCHPIN);
[color=#CC6600]if[/color] (switch_state == [color=#006699]HIGH[/color])
{
[color=#CC6600]digitalWrite[/color](LEDPIN, [color=#006699]HIGH[/color]);
}
[color=#CC6600]else[/color]
{
[color=#CC6600]digitalWrite[/color](LEDPIN, [color=#006699]LOW[/color]);
}
}[color=#7E7E7E]/* --(end main loop )-- */[/color]

[color=#7E7E7E]/* ( THE END ) */[/color]



[/quote]



---( copy for forum into Wikitext Editor )------

[quote]
[color=#7E7E7E]/* YourDuino Electronic Brick Test[/color]
[color=#7E7E7E] Simple Switch type INPUT DEVICES[/color]
[color=#7E7E7E] terry@yourduino.com */[/color]

[color=#7E7E7E]/*-----( Declare Constants )-----*/[/color]
#define SWITCHPIN 2
#define LEDPIN 13

[color=#7E7E7E]/*-----( Declare Variables )-----*/[/color]
[color=#CC6600]int[/color] switch_state; [color=#7E7E7E]/* Holds the last state of the switch */[/color]

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() [color=#7E7E7E]/*----( SETUP: RUNS ONCE )----*/[/color]
{
[color=#CC6600]pinMode[/color](LEDPIN, [color=#006699]OUTPUT[/color]);

}[color=#7E7E7E]/*--(end setup )---*/[/color]


[color=#CC6600]void[/color] [color=#CC6600]loop[/color]() [color=#7E7E7E]/*----( LOOP: RUNS CONSTANTLY )----*/[/color]
{

switch_state = [color=#CC6600]digitalRead[/color](SWITCHPIN);
[color=#CC6600]if[/color] (switch_state == [color=#006699]HIGH[/color])
{
[color=#CC6600]digitalWrite[/color](LEDPIN, [color=#006699]HIGH[/color]);
}
[color=#CC6600]else[/color]
{
[color=#CC6600]digitalWrite[/color](LEDPIN, [color=#006699]LOW[/color]);
}
}[color=#7E7E7E]/* --(end main loop )-- */[/color]

[color=#7E7E7E]/* ( THE END ) */[/color]



[/quote]

----( copy as HTML )----

<br /> <span style="color: #7e7e7e">/* YourDuino Electronic Brick Test</span><br /> <span style="color: #7e7e7e"> Simple Switch type INPUT DEVICES</span><br /> <span style="color: #7e7e7e"> terry@yourduino.com */</span><br /> <br /> <span style="color: #7e7e7e">/*-----( Declare Constants )-----*/</span><br />  #define SWITCHPIN 2<br />  #define LEDPIN    13<br /> <br /> <span style="color: #7e7e7e">/*-----( Declare Variables )-----*/</span><br /> <span style="color: #cc6600">int</span> switch_state; <span style="color: #7e7e7e">/* Holds the last state of the switch */</span><br /> <br /> <span style="color: #cc6600">void <b>setup</b></span>() <span style="color: #7e7e7e">/*----( SETUP: RUNS ONCE )----*/</span><br />  {<br />    <span style="color: #cc6600">pinMode</span>(LEDPIN, <span style="color: #006699">OUTPUT</span>);<br /> <br />  }<span style="color: #7e7e7e">/*--(end setup )---*/</span><br /> <br /> <br /> <span style="color: #cc6600">void loop</span>() <span style="color: #7e7e7e">/*----( LOOP: RUNS CONSTANTLY )----*/</span><br />  {<br /> <br />    switch_state = <span style="color: #cc6600">digitalRead</span>(SWITCHPIN); <br />    <span style="color: #cc6600">if</span> (switch_state == <span style="color: #006699">HIGH</span>)<br />    {<br />      <span style="color: #cc6600">digitalWrite</span>(LEDPIN, <span style="color: #006699">HIGH</span>);<br />    }  <br />    <span style="color: #cc6600">else</span><br />    {<br />      <span style="color: #cc6600">digitalWrite</span>(LEDPIN, <span style="color: #006699">LOW</span>);<br />    }<br />  }<span style="color: #7e7e7e">/* --(end main loop )-- */</span><br /> <br /> <span style="color: #7e7e7e">/* ( THE END ) */</span><br /> <br /> <br /> <br />  



---( copy as HTML into Wikitext )------




/* YourDuino Electronic Brick Test
 Simple Switch type INPUT DEVICES
 terry@yourduino.com */

/*-----( Declare Constants )-----*/
#define SWITCHPIN 2
#define LEDPIN    13

/*-----( Declare Variables )-----*/
int switch_state; /* Holds the last state of the switch */

void setup() /*----( SETUP: RUNS ONCE )----*/
{
  pinMode(LEDPIN, OUTPUT);

}/*--(end setup )---*/


void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{

  switch_state = digitalRead(SWITCHPIN);
  if (switch_state == HIGH)
  {
    digitalWrite(LEDPIN, HIGH);
  }  
  else
  {
    digitalWrite(LEDPIN, LOW);
  }
}/* --(end main loop )-- */

/* ( THE END ) */

---( Save as HTML, remove all bkspaces, insert in wikitext)_---



/* YourDuino Electronic Brick Test
Simple Switch type INPUT DEVICES
terry@yourduino.com */

/*-----( Declare Constants )-----*/
#define SWITCHPIN 2
#define LEDPIN 13

/*-----( Declare Variables )-----*/
int switch_state; /* Holds the last state of the switch */

void setup() /*----( SETUP: RUNS ONCE )----*/
{
pinMode(LEDPIN, OUTPUT);

}/*--(end setup )---*/


void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{

switch_state = digitalRead(SWITCHPIN);
if (switch_state == HIGH)
{
digitalWrite(LEDPIN, HIGH);
}
else
{
digitalWrite(LEDPIN, LOW);
}
}/* --(end main loop )-- */

/* ( THE END ) */