Програмиране на малки микропроцесорни системи
-
Upload
neven-boyanov -
Category
Devices & Hardware
-
view
583 -
download
6
Transcript of Програмиране на малки микропроцесорни системи
/2014-05-27
:)
!
Raspberry Pi C/C++
#include int main (void){ wiringPiSetup (); pinMode (0, OUTPUT); for (;;) { digitalWrite (0, HIGH); delay (500); digitalWrite (0, LOW); delay (500); } return 0;}
Raspberry Pi Python
import RPi.GPIO as GPIOimport time# blinking functiondef blink(pin): GPIO.output(pin,GPIO.HIGH) time.sleep(1) GPIO.output(pin,GPIO.LOW) time.sleep(1) return# to use Raspberry Pi board pin numbersGPIO.setmode(GPIO.BOARD)# set up GPIO output channelGPIO.setup(11, GPIO.OUT)# blink GPIO17 50 timesfor i in range(0,50): blink(11)GPIO.cleanup()
Arduino C/C++
// 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 delay(1000); // wait for a second digitalWrite(led, LOW); // turn the LED off delay(1000); // wait for a second}
ATtiny85 C/C++
#include #include // Define the I/O port to be used for the LED.// This a number between 0 and 7 that tells which bit to use.#define LED_PORT PB3int main(void) { // Set the LED port number as output. // The DDRB is the data direction for port B. // - shifts the "1" on left to the desired position and ... // - does bitwise "OR" with the value in the port register. DDRB |= (1