Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Servo servo1;
- void setup() {
- // put your setup code here, to run once:
- servo1.attach(6);
- Serial.begin(9600);
- Serial.println("Start");
- }
- void loop() {
- // put your main code here, to run repeatedly:
- for(int i = 0; i < 180; i += 10)
- {
- Serial.println(i);
- delay(3000);
- servo1.write(i);
- }
- }
- -------------------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO.Ports;
- namespace WindowsFormsApplication3
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- comboBox1.Items.Clear();
- foreach (string portName in SerialPort.GetPortNames())
- {
- comboBox1.Items.Add(portName);
- }
- comboBox1.SelectedIndex = 0;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- serialPort1.Open();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- serialPort1.Close();
- }
- private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
- {
- SerialPort sp = (SerialPort)sender;
- label1.Text = sp.ReadExisting();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement