Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arduino k��i
- python k��inn er fyrir ne�an
- //working k��i
- // ssh root@ yourYunsName.local 'telnet localhost 6571'
- #include <Console.h>
- #include <Servo.h>
- const int ledPin = 13; // the pin that the LED is attached to
- char ib; // a variable to read incoming Console data into
- Servo servo1;
- void setup()
- {
- servo1.attach(6); // Attach servo to pin 7
- Bridge.begin(); // Initialize Bridge
- Console.begin(); // Initialize Console
- pinMode(3, OUTPUT); // tone
- // Wait for the Console port to connect
- while(!Console);
- Console.println("READY");
- tone (3, 800, 200);
- delay (200);
- // initialize the LED pin as an output:
- pinMode(ledPin, OUTPUT);
- }
- void loop() {
- // see if there's incoming Console data:
- if (Console.available() > 0) {
- // read the oldest byte in the Console buffer:
- ib = Console.read();
- if (ib == 'S') // if Byte is S
- {
- uint8_t b1 = Console.read (); //read next 3 numbers that come after S
- uint8_t b2 = Console.read ();
- uint8_t b3 = Console.read ();
- servo1.write((b1 - '0')*100 + (b2 - '0')*10 + b3 - '0');
- }
- // if it's a capital H (ASCII 72), turn on the LED:
- if (ib == 'H') {
- digitalWrite(ledPin, HIGH);
- }
- // if it's an L (ASCII 76) turn off the LED:
- if (ib == 'L') {
- digitalWrite(ledPin, LOW);
- }
- }
- }
- python k��i
- import telnetlib
- import time
- import sys
- HOST = "localhost"
- PORT = "6571"
- tn = telnetlib.Telnet(HOST, PORT)
- tn.write("S090\n\r")
- time.sleep(1)
- tn.write("S080\n\r")
- time.sleep(1)
- tn.close()
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement