1.0.5-r2

http://sites.schaltungen.at/arduino-uno-r4/1-0-5-r2

http://www.linksammlung.info/

http://www.schaltungen.at/

                                                                                       Wels, am 2014-05-10

BITTE nützen Sie doch rechts OBEN das Suchfeld  [                                                              ] [ Diese Site durchsuchen]

DIN A3 oder DIN A4 quer ausdrucken
**********************************************************************************
DIN A4  ausdrucken
*********************************************************
ARDUINO-Programm-Version  STAND  2012
Arduino 1.0.5-r2   ist die neueste Arduino 1.0 Release Candidate 2 (RC2)

Bisher Release 001

Endungen von *.ino in *.pde ändern um den Sketch in eine Pre-1.0-IDE laden zu können.

Baumstrukturen sind zwar gut zum Programmieren.
Wenn man sich einen ersten schnellen Überblick verschaffen möchte ist eine Excel-Liste besser.
Ich habe mir die Arbeit gemacht eine solche über alle ARDUINO-Sketche zu erstellen wie ich dies vor 30 Jahren auch immer tat.
Nach dekadischem Nummernsystem / dekadische Gliederung.
http://de.wikipedia.org/wiki/Nummerung

Deutsche Übersetzungen einiger Arduino Tutorials sind hier zu finden:
http://playground.arduino.cc/Deutsch/HomePage





*********************************************************
ARDUINO > Learning > Examples
http://arduino.cc/en/Tutorial/HomePage

Entwicklungsumgebung ARDUINO UNO R3
Programmiersprache "Processing"

Sketch'es


MENU > Datei > Beispiele


01.Basics
02.Digital
03.Analog
04.Communication
05.Control
06.Sensors
07.Display
08.Strings
09.USB 4
10.StarterkKit
11.ArduinoISP

12.EEPROM
13.Esplora
14.Ethernet
15.Firmata
16.GSM
17.LiquidCrystal
18.Robot_Control
19. Robot_Motor
20.SD
21.Servo
22.SoftwareSerial
23.SPI
24.Stepper
25.TFT
26.WiFi
27.Wire


Diese Tabelle ist auch mit den dabei verwendeten Elektronik-Bauteilen vorhanden,

Wurde in akribischer Kleinarbeit mit viel Zeitaufwabd erstellt, daher nur downloadbar unter
www.schaltungen.at

704_d_ARDUINO-x_1.0.5-r2 – MENU - Datei - Beispiele_2a.xls




704_d_ARDUINO-x_1.0.5-r2 – MENU - Datei - Beispiele_1a.xls











00
00
00

01 Basis 01 AnalogReadSerial

Analog Read Serial
01 Basis 02 BareMinimum

Bare Minimum
01 Basis 03 Blink

Blink
01 Basis 04 DigitalReadSerial

Digital Read Serial
01 Basis 05 Fade

Fade
01 Basis 06 ReadAnalogVollage

Read Analog Vollage







02 Digital 01 BlinkWithoutDelay

Blink With out Delay
02 Digital 02 Button

Button
02 Digital 03 Debounce

Debounce
02 Digital 04 DigitallnputPullup

Digital lnput Pullup
02 Digital 05 StateChangeDatection

State Change Datection
02 Digital 06 toneKeyoard

tone Keyoard
02 Digital 07 toneMelody

tone Melody
02 Digital 08 toneMultiple

tone Multiple
02 Digital 09 tonePitchFollower

tone Pitch Follower







03 Analog 01 AnalogInOutSerial

Analog In Out Serial
03 Analog 02 AnalogInput

Analog Input
03 Analog 03 AnalogWriteMega

Analog Write Mega
03 Analog 04 Calibration

Calibration
03 Analog 05 Fading

Fading
03 Analog 06 Smoothing

Smoothing







04 Comunication 01 ASCIlTable

ASCIl Table
04 Comunication 02 Dimmer

Dimmer
04 Comunication 03 Graph

Graph
04 Comunication 04 MIDI

MIDI
04 Comunication 05 MultiSerialMega

Multi Serial Mega
04 Comunication 06 PhysicalPixel

Physical Pixel
04 Comunication 07 ReadASCIIString

Read ASCII String
04 Comunication 08 SenalCallResponse

Senal Call Response
04 Comunication 09 SerialCallResponseASCII

Serial Call Response ASCII
04 Comunication 10 SerialEvent

Serial Event
04 Comunication 11 VirtualColorMixer

Virtual Color Mixer







05 Control Structures 01 Array

Array
05 Control 02 ForLoop

For Loop
05 Control 03 IfStatementConditional

If Statement Conditional
05 Control 04 switchCase

switch Case 1
05 Control 05 switchCase2

switch Case 2
05 Control 06 WhileLoop

While Loop







06 Sensors 01 ADXL3xx

ADXL 3xx
06 Sensors 02 Knock

Knock
06 Sensors 03 Memsic2125

Memsic 2125
06 Sensors 04 Ping

Ping







07 Display 01 LEDbarGraph

LED bar Graph
07 Display 02 RowColumnScanning

Row Column Scanning







08 String 01 CharacterAnalysis

Character Analysis
08 String 02 StringAdditionOperator

String Addition Operator
08 String 03 StringAppendOperator

String Append Operator
08 String 04 StringCaseChanges

String Case Changes
08 String 05 StringCharacters

String Characters
08 String 06 StringComparisonOperators

String Comparison Operators
08 String 07 StringConstructors

String Constructors
08 String 08 StringIndexOf

String Index Of
08 String 09 StringLength

String Length
08 String 10 StringLengthTrim

String Length Trim
08 String 11 StringReplace

String Replace
08 String 12 StrigStartsWithEndsWith

Strig Starts With Ends With
08 String 13 StringSubstring

String Substring
08 String 14 StringToInt

String To Int
08 String 15 StringToIntRGB

String To Int RGB







09 USB 01 Keyboard 01 KeyboardLogout Keyboard Logout
09 USB 01 Keyboard 02 KeyboardMessage Keyboard Message
09 USB 01 Keyboard 03 KeyboardReprogram Keyboard Reprogram
09 USB 01 Keyboard 04 KeyboardSerial Keyboard Serial
09 USB 02 KeyboardAndMouseControl

Keyboard and Mouse Control
09 USB 03 Mause 01 ButtonMouseControl Button Mouse Control
09 USB 03 Mause 02 JoystickMouseControl Joystick Mouse Control







10 StarterKit 01 fehlt

fehlt
10 StarterKit 02 p02_Spaceshipinterface

Space ship Interface
10 StarterKit 03 p03_LoveOMeter

Love O Meter
10 StarterKit 04 p04_ColorMixingLamp

Color Mixing Lamp
10 StarterKit 05 p05_ServoMoodIndicator

Servo Mood Indicator
10 StarterKit 06 r06_LightTheremin

Light Theremin
10 StarterKit 07 p07_Keyboard

Keyboard
10 StarterKit 08 p98_DigitalHourglass

Digital Hourglass
10 StarterKit 09 p09_MotorizedPinwheel

Motorized Pinwheel
10 StarterKit 10 p10_Zoetrope

Zoetrope
10 StarterKit 11 p11_CrystalBall

Crystal Ball
10 StarterKit 12 p12_KnockLock_

Knock Lock_
10 StarterKit 13 p13 JouchSerisorLamp

Jouch Serisor Lamp
10 StarterKit 14 p14_TvveakTheArduinoLogo

Tvveak The Arduino Logo
10 StarterKit 15 p15_HackingButtons

Hacking Buttons







11 ArduinoSP
Bridge





Console ASCII Table





Console Pixel





Console Read





Datalogger





File Write Script





HTTP Client





Process





Shell Commands





Temperature Web Panel





TimeCheck





WiFiStatus





Xively Client





Yun Serial Terminal





MailboxReadMessage





Pacakage Manager





Extending Yun disk space
















12 EEPROM 01 eeprom_clear

EEPROM Clear
12 EEPROM 02 eeprorn_read

EEPROM Read
12 EEPROM 03 eeprom_write

EEPROM Write







13 Esplora 01 Beginners 01 EsploraAccelerometer Esplora Accelerometer
13 Esplora 01 Beginners 02 EsploraBlink Esplora Blink
13 Esplora 01 Beginners 03 EsploraJoystickMouse Esplora Joystick Mouse
13 Esplora 01 Beginners 04 EsploraLedShow Esplora Led Show 1
13 Esplora 01 Beginners 05 EsploraLedShow2 Esplora Led Show 2
13 Esplora 01 Beginners 06 EsploraLightCatibrator Esplora Light Catibrator
13 Esplora 01 Beginners 07 EsploraMusic Esplora Music
13 Esplora 01 Beginners 08 EsploraSoundSensor Esplora Sound Sensor
13 Esplora 01 Beginners 09 EsploraTemperatureSensor Esplora Temperature Sensor
13





13 Esplora 02 Experts 01 EsploraKart Esplora Kart
13 Esplora 02 Experts 02 EsploraPong Esplora Pong
13 Esplora 02 Experts 03 EsploraRemote Esplora Remote
13 Esplora 02 Experts 04 EsploraTable Esplora Table







14 Ethernet 01 BarometricPressureWebServer

Barometric Pressure Web Server
14 Ethernet 02 ChatServer

DHCP Chat Server
14 Ethernet 03 DhcpAddressPrinter

DHCP Address Printer
14 Ethernet 04 DhcpChatServer

Chat Server
14 Ethernet 05 PachubeCIient

Pachube CIient
14 Ethernet 06 PachubeClientString

Pachube Client String
14 Ethernet 07 TelnetClient

Telnet Client
14 Ethernet 08 TwitterClient

Twitter Client
14 Ethernet 09 UdpNtpClient

UDP Ntp Client
14 Ethernet 10 UDPSendReceiveString

UDP Send Receive String
14 Ethernet 11 WebClient

Web Client
14 Ethernet 12 WebClientRepeating

Web Client Repeating
14 Ethernet 13 WebServer

Web Server







15 Firmata 01 AllInputsFirmata

AllInputs Firmata
15 Firmata 02 AnalogFirmata

Analog Firmata
15 Firmata 03 EchoString

Echo String
15 Firmata 04 I2CFirmata

I2C Firmata
15 Firmata 05 OldStandardFirmata

Old Standard Firmata
15 Firmata 06 ServoFirmata

Servo Firmata
15 Firmata 07 SimpleAnalogFirmata

Simple Analog Firmata
15 Firmata 08 SimpleDigitalFIrmata

Simple Digital FIrmata
15 Firmata 09 StandadFirmata

Standad Firmata







16 GSM 01 GSMPachubeClient

Pachube Client
16 GSM 02 GSMPachubeClientString

Pachube Client String
16 GSM 03 GSMTwitterClient

Twitter Client
16 GSM 04 GSMWebClient

Web Client
16 GSM 05 GSMWebServer

Web Server
16 GSM 06 MakeVoiceCall

Make Voice Call
16 GSM 07 RecerveSMS

Recerve SMS
16 GSM 08 SendSMS

Send SMS
16 GSM 09 Tools 01 BandManagement Band Management
16 GSM 09 Tools 02 GSMScanNetworks Scan Networks
16 GSM 09 Tools 03 PinManagement Pin Management
16 GSM 09 Tools 04 TestGPRS Test GPRS
16 GSM 09 Tools 05 TestModem Test Modem
16 GSM 09 Tools 06 TestWebServer Test Web Server







17 LiquidCrystal 01 Autoscroll

Autoscroll
17 LiquidCrystal 02 Blink

Blink
17 LiquidCrystal 03 Cursor

Cursor
17 LiquidCrystal 04 CustomCharacter

Custorn Character
17 LiquidCrystal 05 Display

Display
17 LiquidCrystal 06 HelloWorld

Hello World
17 LiquidCrystal 07 Scroll

Scroll
17 LiquidCrystal 08 Seria!Display

Seria! Display
17 LiquidCrystal 09 setCursor

set Cursor
17 LiquidCrystal 10 TextDirection

Text Direction







18 Robot_Control 01 explore 01 R01_Logo Logo
18 Robot_Control 01 explore 02 R02_Line_Following Line_Following
18 Robot_Control 01 explore 03 R03_Disco_Bot Disco Bot
18 Robot_Control 01 explore 04 R04_Compass Compass
18 Robot_Control 01 explore 05 R05_Inputs Inputs
18 Robot_Control 01 explore 06 R06_Wheel_Calibralion Wheel Calibralion
18 Robot_Control 01 explore 07 R07_Runaway_Robot Runaway Robot
18 Robot_Control 01 explore 08 R08_Remote_Control Remote Control
18 Robot_Control 01 explore 09 R09_Picture_Browser Picture Browser
18 Robot_Control 01 explore 10 R10_Rescue Rescue
18 Robot_Control 01 explore 11 R11_Hello_User Hello User
18





18 Robot_Control 02 learn 01 AllIOPorts All IO Ports
18 Robot_Control 02 learn 02 Beep Beep
18 Robot_Control 02 learn 03 CleanEEPROM Clean EEPROM
18 Robot_Control 02 learn 04 Compass Compass
18 Robot_Control 02 learn 05 IRArray IR Array
18 Robot_Control 02 learn 06 keyboardTest Keyboard Test
18 Robot_Control 02 learn 07 LCDDebugPrint LCD Debug Print
18 Robot_Control 02 learn 08 LCDPrint LCD Print
18 Robot_Control 02 learn 09 LCDWriteText LCD Write Text
18 Robot_Control 02 learn 10 LineFollowWithPause Line Follow With Pause
18 Robot_Control 02 learn 11 Melody Melody
18 Robot_Control 02 learn 12 MotorTest Motor Test
18 Robot_Control 02 learn 13 SpeedByPotentiometer Speed by Potentiometer
18 Robot_Control 02 learn 14 TurnTest Turn Test







19 Robot_Motor 01 Robot_IR_Array_Test

Robot IR Array Test
19 Robot_Motor 02 Robot_Motor_Core

Robot Motor Core







20 SD 01 CardInfo

Card Info
20 SD 02 Datalogger

Datalogger
20 SD 03 DumpFile

Dump File
20 SD 04 Files

Files
20 SD 05 ListFiles

List Files
20 SD 06 ReadWrite

Read Write







21 Servo 01 Knob

Knob
21 Servo 02 Sweep

Sweep







22 SoftwareSerial 01 SoftwareSerialExample

Software Serial Example
22 SoftwareSerial 02 TwoPortReceive

Two Port Receive







23 SPI 01 BarometricPressureSensor

Barometric Pressure Sensor
23 SPI 02 SPIDigitalPotControl
AD5206 SPIDigitalPotControl







24 Stepper
MotorKnob

Motor Knob
24 Stepper
stepper_oneRevolution

stepper one Revolution
24 Stepper
stepper_oneStepAtATime

stepper one Step AtA Time
24 Stepper
stepper_speedControl

stepper speed Control







25 TFT 01 ARDUINO UNO R3 01 TFTBitmapLogo TFT Bitmap Logo
25 TFT 01 ARDUINO UNO R4 02 TFTColorPicker TFT Color Picker
25 TFT 01 ARDUINO UNO R5 03 TFTDisplayText TFT Display Text
25 TFT 01 ARDUINO UNO R6 04 TFTEtchASketch TFT Etch a Sketch
25 TFT 01 ARDUINO UNO R7 05 TFTGraph TFT Graph
25 TFT 01 ARDUINO UNO R8 06 TFTPong TFT Pong







26 WiFi 01 ConnectNoEncryption

Connect no Encryption
26 WiFi 02 ConnectWithWEB

Connect With WEB
26 WiFi 03 ConnectWithWPA

Connect With WPA
26 WiFi 04 ScanNetworks

Scan Networks
26 WiFi 05 SirnpleWebServerWiFi

Sirnple Web Server WiFi
26 WiFi 06 WiFiChartServer

WiFi Chart Server
26 WiFi 07 WiFiPachubeClient

WiFi Pachube Client
26 WiFi 08 WiFiPachubeClientString

WiFi Pachube Client String
26 WiFi 09 WiFiTwitterClient

WiFi Twitter Client
26 WiFi 10 WiFiUdpNtpClient

WiFi UDP Ntp Client
26 WiFi 11 WiFiUdpSendReceiveString

WiFi UDP Send Receive String
26 WiFi 12 WiFiWebClient

WiFi Web Client
26 WiFi 13 WiFiWebClientRepeating

WiFi Web Client Repeating
26 WiFi 14 WiFiWebServer

WiFi Web Server







27 Wire 01 digitalPotentiometer

digital Potentiometer
27 Wire 02 rnaster_reader

rnaster reader
27 Wire 03 master_writer

master writer
27 Wire 04 SFRRanger_reader

SFR Ranger reader
27 Wire 05 slave_receiver

slave Receiver
27 Wire 06 slave_sender

slave Sender






















































*********************************************************

Ich persönlich finde ja die Videos im Internet unsinnig.
Eine Schaltung versteht man nur wenn man auch einen Schaltplan lesen kann.
Farbige Kabel in Bread-Bords gesteckt geht schnell aber die Schaltungsfunktion ist kein bisschen verstädnlich.

Ferner ist zu bemerken  diese Anfängerschaltungen mit meist nur 3 Bauteilen kann man auch fliegend am ARDUINO stecken.

Beim Programm schreibe passiert es mir immer mal wieder das ich keine geschweiften Klammern setze.
Bei schlechten Kopien schauen diese aus wie runde Klammern.

Und überall steht 9600 Baud das BOARD und der USB-PORT  kann aber heute 115200 Baud, daher verwende ich diese Geschwindigkeit.

Auf D13 (SCK) ist eine LED schon eingebaut daher wird extern keine LED benötigt,
sollte aber eine LED PWM angesteuert werden geht dies nur am pin D3 D5 D6 D9 D10 D11




Andere Darstellungsart mit zusätzlicher Pin-Bezeichnung  D13 (SCK)  aber D13 ist immer D13 und da hängt auch die eingebaute LED uber einen OpAmp daran.







*********************************************************

1.Basics



01 Basis 01 AnalogReadSerial


/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 */


// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}






01 Basis 02 BareMinimum

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
 
}


01 Basis 03 Blink




/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 */

 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:

int led = 13;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);    
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}




01 Basis 04 DigitalReadSerial


/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor
 */


// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println(buttonState);
  delay(1);        // delay in between reads for stability
}



01 Basis 05 Fade





/*
 Fade
 This example shows how to fade an LED on pin 9
 using the analogWrite() function.
 */


int led = 9;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup()  {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop()  {
  // set the brightness of pin 9:
  analogWrite(led, brightness);    

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:

  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }    
  // wait for 30 milliseconds to see the dimming effect    
  delay(30);                            
}




01 Basis 06 ReadAnalogVollage





/*
  ReadAnalogVoltage
  Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 */


// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
}





*********************************************************

2.Digital


02 Digital 01 BlinkWithoutDelay



/* Blink without Delay
 Turns on and off a light emitting diode(LED) connected to a digital  pin, without using the delay() function.  This means that other code
 can run at the same time without being interrupted by the LED code.
 The circuit:
 * LED attached from pin 13 to ground.
 * Note: on most Arduinos, there is already an LED on the board
 that's attached to pin 13, so no hardware is needed for this example.
http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
 */


// constants won't change. Used here to
// set pin numbers:

const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to blink (milliseconds)

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

void loop()
{
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the
  // difference between the current time and last time you blinked
  // the LED is bigger than the interval at which you want to
  // blink the LED.

  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;  

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}




02 Digital 02 Button




/*
  Button
 Turns on and off a light emitting diode(LED) connected to digital  pin 13, when pressing a pushbutton attached to pin 2.
 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 
 * Note: on most Arduinos there is already an LED on the board attached to pin 13.
.http://www.arduino.cc/en/Tutorial/Button
 */


// constants won't change. They're used here to
// set pin numbers:

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);    
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:

  if (buttonState == HIGH) {    
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}



02 Digital 03 Debounce



/*
 Debounce
 Each time the input pin goes from LOW to HIGH (e.g. because of a push-button press), the output pin is toggled from LOW to HIGH or HIGH to LOW.  There's
 a minimum delay between toggles to debounce the circuit (i.e. to ignore noise). 
 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached from pin 2 to +5V
 * 10K resistor attached from pin 2 to ground
 * Note: On most Arduino boards, there is already an LED on the board
 connected to pin 13, so you don't need any extra components for this example.
http://www.arduino.cc/en/Tutorial/Debounce
 */


// constants won't change. They're used here to
// set pin numbers:

const int buttonPin = 2;    // the number of the pushbutton pin
const int ledPin = 13;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);

  // set initial LED state

  digitalWrite(ledPin, ledState);
}

void loop() {
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH),  and you've waited
  // long enough since the last press to ignore any noise:  

  // If the switch changed, due to noise or pressing:

  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
 
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:


    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        ledState = !ledState;
      }
    }
  }
 
  // set the LED:
  digitalWrite(ledPin, ledState);

  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:

  lastButtonState = reading;
}




Button State Change:


/*
  State change detection (edge detection) 
 Often, you don't need to know the state of a digital input all the time, but you just need to know when the input changes from one state to another.
 For example, you want to know when a button goes from OFF to ON.  This is called state change detection, or edge detection.
 This example shows how to detect when a button or button changes from off to on and on to off. 
 The circuit:
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 * LED attached from pin 13 to ground (or use the built-in LED on most Arduino boards)
http://arduino.cc/en/Tutorial/ButtonStateChange
*/

// this constant won't change:
const int  buttonPin = 2;    // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communication:
  Serial.begin(115200);
}


void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button
      // wend from off to on:
      buttonPushCounter++;
      Serial.println("on");
      Serial.print("number of button pushes:  ");
      Serial.println(buttonPushCounter);
    }
    else {
      // if the current state is LOW then the button
      // wend from on to off:
      Serial.println("off");
    }
  }
  // save the current state as the last state,
  //for next time through the loop
  lastButtonState = buttonState;

 
  // turns on the LED every four button pushes by
  // checking the modulo of the button push counter.
  // the modulo function gives you the remainder of
  // the division of two numbers:
  if (buttonPushCounter % 4 == 0) {
    digitalWrite(ledPin, HIGH);
  } else {
   digitalWrite(ledPin, LOW);
  }
 
}




Input PullUp Serial:



/*
 Input Pullup Serial
 This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a  digital input on pin 2 and prints the results to the serial monitor.
 The circuit:
 * Momentary switch attached from pin 2 to ground
 * Built-in LED on pin 13
 Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal  20k Ohm resistor is pulled to 5V. This configuration causes the input to read HIGH when the switch is open, and LOW when it is closed.
http://www.arduino.cc/en/Tutorial/InputPullupSerial
*/


void setup(){
  //start serial connection
  Serial.begin(115200);
  //configure pin2 as an input and enable the internal pull-up resistor
  pinMode(2, INPUT_PULLUP);
  pinMode(13, OUTPUT);

}

void loop(){
  //read the pushbutton value into a variable
  int sensorVal = digitalRead(2);
  //print out the value of the pushbutton
  Serial.println(sensorVal);
 
  // Keep in mind the pullup means the pushbutton's
  // logic is inverted. It goes HIGH when it's open,
  // and LOW when it's pressed. Turn on pin 13 when the
  // button's pressed, and off when it's not:
  if (sensorVal == HIGH) {
    digitalWrite(13, LOW);
  }
  else {
    digitalWrite(13, HIGH);
  }
}



Tone:




/*
  Melody
Plays a melody
 circuit: * 8-ohm speaker on digital pin 8
http://arduino.cc/en/Tutorial/Tone
*/


 #include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4,4,4,4,4 };

void setup() {
  // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 8; thisNote++) {

    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(8);
  }
}

void loop() {
  // no need to repeat the melody.
}




Pitch follower:





/*
  Pitch follower
 Plays a pitch that changes based on a changing analog input
 circuit:
 * 8-ohm speaker on digital pin 9
 * photoresistor on analog 0 to 5V
 * 4.7K resistor on analog 0 to ground
http://arduino.cc/en/Tutorial/Tone2
 */


void setup() {
  // initialize serial communications (for debugging only):
  Serial.begin(115200);
}

void loop() {
  // read the sensor:
  int sensorReading = analogRead(A0);
  // print the sensor reading so you know its range
  Serial.println(sensorReading);
  // map the analog input range (in this case, 400 - 1000 from the photoresistor)
  // to the output pitch range (120 - 1500Hz)
  // change the minimum and maximum input numbers below
  // depending on the range your sensor's giving:
  int thisPitch = map(sensorReading, 400, 1000, 120, 1500);

  // play the pitch:
  tone(9, thisPitch, 10);
  delay(1);        // delay in between reads for stability
}




Simple Keyboard:




/*
  keyboard
 Plays a pitch that changes based on a changing analog input
 circuit:
 * 3 force-sensing resistors from +5V to analog in 0 through 5
 * 3 10K resistors from analog in 0 through 5 to ground
 * 8-ohm speaker on digital pin 8
http://arduino.cc/en/Tutorial/Tone3
 */


#include "pitches.h"

const int threshold = 10;    // minimum reading of the sensors that generates a note

// notes to play, corresponding to the 3 sensors:
int notes[] = {
  NOTE_A4, NOTE_B4,NOTE_C3 };

void setup() {

}

void loop() {
  for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
    // get a sensor reading:
    int sensorReading = analogRead(thisSensor);

    // if the sensor is pressed hard enough:
    if (sensorReading > threshold) {
      // play the note corresponding to this sensor:
      tone(8, notes[thisSensor], 20);
    }
  }
}



/*************************************************
 * Public Constants
 *************************************************/


#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978




Tone4:





/*
  Multiple tone player
 Plays multiple tones on multiple pins in sequence
 circuit:
 * 3 8-ohm speaker on digital pins 6, 7, and 8
 http://arduino.cc/en/Tutorial/Tone4
 */


void setup() {

}

void loop() {
  // turn off tone function for pin 8:
  noTone(8);           
  // play a note on pin 6 for 200 ms:
  tone(6, 440, 200);
  delay(200);

  // turn off tone function for pin 6:
  noTone(6);
  // play a note on pin 7 for 500 ms:
  tone(7, 494, 500);
  delay(500);
 
  // turn off tone function for pin 7:
  noTone(7);  
  // play a note on pin 8 for 500 ms:
  tone(8, 523, 300);
  delay(300);
}




*********************************************************
Weitere Beispiele habe ich mir erspart da ohnehin alles mehrmals im Internet zu finden ist.
Jeder kupfert wie ich auch, von jemanden ab, macht dabei Fehler und schon geht nichts mehr.
Ein Grundlagen Buch und sich selbst etwas einlesen damit man auch seine Fehler suchen und finden kann, wird notwendig sein.
Ohne Fleiß kein Preis






DIN A4  ausdrucken
*********************************************************
Impressum: Fritz Prenninger, Haidestr. 11A, A-4600 Wels, Ober-Österreich, mailto:[email protected]
ENDE