Arduino Euskeraz 03

2
Praktika honetan informazioa bidaliko diogu ordenagailuari irakurri ahal izateko. Aldi berean potentziometro batetik datorren seinale analogikoak irakurtzen ikasiko dugu. Muntatu potentziometro bat behean agertzen den moduan eta kargatu alboan dagoen sketch-a. Potentziometroak 5v-0v arteko seinale bat ematen du eta Arduino plakak 1023-0 arteko balioak erabiltzen ditu seinale analogiko hori gordetzeko. Serial port-ean idatzitako guztia ikusi ahal izateko sakatu Arduino-IDEn aurkitu daitekeen alboko ikurrari. Leiho berri bat zabalduko da non datu guztiak ikusgai izango dituzun. POTENCIOMETER a variable resistor with three pins. Two of the pins are connected to the ends of a fixed resistor. The middle pin moves across the resistor, dividing it into two halves. When the external sides of the potentiometer are connected to voltage and ground, the middle leg will give the difference in voltage as turn the knob. Description Syntax Serial.begin() Used for start the communication between the Arduino board and a computer or other devices. It opens the serial pot and sets the data rate in bits per second (baud) for serial data transmission. Serial.begin(speed) speed: in bits per second (baud) Serial.print() Serial.pintln() Prints data to the serial port as human-readable Prints data to the serial port as human-readable followed by a carriage return character and a newline character. This command takes the same forms as Serial.print(). Serial.print(val) Serial.println(val) val: the value to print - any data type analogRead() Reads the value from the specified analog pin. The Arduino board contains a 6 channel, 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023. This yields a resolution between readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV) per unit. analogRead(pin) pin: the number of the analog input pin to read from analogWrite() PWM ~ Writes an analog value (PWR waves) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite(). This function works on pins 3, 5, 6, 9, 10, and 11. You do not need to call pinMode() to set the pin as an output before calling analogWrite(). The analogWrite function has nothing whatsoever to do with the analog pins or the analogRead function. analogWrite(pin, value) pin: the pin to write to. value: the duty cycle: between 0 (always off) and 255 (always on). PRAKTIKA 3. Potenciometer

Transcript of Arduino Euskeraz 03

  • Praktika honetan informazioa bidaliko diogu ordenagailuariirakurri ahal izateko. Aldi berean potentziometro batetikdatorren seinale analogikoak irakurtzen ikasiko dugu.

    Muntatu potentziometrobat behean agertzen denmoduan eta kargatualboan dagoen sketch-a.

    Potentziometroak 5v-0varteko seinale bat ematendu eta Arduino plakak1023-0 arteko balioakerabiltzen ditu seinaleanalogiko hori gordetzeko.

    Serial port-ean idatzitako guztia ikusi ahal izateko sakatuArduino-IDEn aurkitu daitekeen alboko ikurrari.Leiho berri bat zabalduko da non datu guztiak ikusgai izangodituzun.

    POTENCIOMETER a variable resistor with three pins. Two of the pins are connected to the ends of a fixedresistor. The middle pin moves across the resistor, dividing it into two halves. When the external sides of thepotentiometer are connected to voltage and ground, the middle leg will give the difference in voltage asturn the knob.

    Description Syntax

    Serial.begin() Used for start the communication between the Arduino board anda computer or other devices. It opens the serial pot and sets the data rate in bits per second(baud) for serial data transmission.

    Serial.begin(speed)

    speed: in bits per second (baud)

    Serial.print()

    Serial.pintln()

    Prints data to the serial port as human-readable

    Prints data to the serial port as human-readable followed by acarriage return character and a newline character. This commandtakes the same forms as Serial.print().

    Serial.print(val)Serial.println(val)

    val: the value to print - any data type

    analogRead() Reads the value from the specified analog pin. The Arduino boardcontains a 6 channel, 10-bit analog to digital converter. Thismeans that it will map input voltages between 0 and 5 volts intointeger values between 0 and 1023. This yields a resolutionbetween readings of: 5 volts / 1024 units or, .0049 volts (4.9 mV)per unit.

    analogRead(pin)

    pin: the number of the analog inputpin to read from

    analogWrite()

    PWM ~

    Writes an analog value (PWR waves) to a pin. Can be used to lighta LED at varying brightnesses or drive a motor at various speeds.After a call to analogWrite(), the pin will generate a steady squarewave of the specified duty cycle until the next callto analogWrite().This function works on pins 3, 5, 6, 9, 10, and 11. You do not needto call pinMode() to set the pin as an output before callinganalogWrite().The analogWrite function has nothing whatsoever to do with theanalog pins or the analogRead function.

    analogWrite(pin, value)

    pin: the pin to write to.value: the duty cycle: between 0(always off) and 255 (always on).

    PRAKTIKA 3. Potenciometer

  • EGITEKOAPotentziometroaren balioaren arabera aldatu LEDak duen piztu-itzaliabiadura. Horretarako erabili digitalWrite(pin,mode) eta delay(ms).

    Saiatu orain LEDaren argitasuna aldatzen potentziometroak hartzenduen balioaren arabera. Horretarako erabili beharko duzu Arduinoplakaren ~3, ~5, ~6, ~9, ~10 edo ~11 PINak, hauek baitira 5v eta 0vartean balioa aldatzeko gai diren bakarrak. analogWrite(pin, value)ere erabili behar izango duzu.