Shape Visual Studio and Arduino
Shape Visual Studio and Arduino
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;
namespace WindowsFormsApplication7
Graphics circle;
int y = 140;
int x = 130;
String g = "";
public Form1()
InitializeComponent();
}
private void oPENToolStripMenuItem_Click(object sender, EventArgs e)
serialPort1.Open();
serialPort1.Close();
circle = e.Graphics;
if (g == "0")
{ x = x + 10; }
else if (g == "1")
{ x = x - 10; }
else if (g == "2")
{ y = y + 10; }
else if (g == "3")
{ y = y - 10; }
else if (g == "4")
{
x = x;
y = y;
this.Refresh();
x = 130;
y = 140;
timer1.Enabled = true;
g = serialPort1.ReadExisting();
}
ARDUINO
void setup() {
pinMode(10,INPUT);
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(13,INPUT);
Serial.begin(9600);// 115200
while (!Serial) {
void loop() {
if(digitalRead(10)==HIGH){
Serial.print("0");
else if(digitalRead(11)==HIGH){
Serial.print("1");
else if(digitalRead(12)==HIGH){
Serial.print("2");
else if(digitalRead(13)==HIGH){
Serial.print("3");
else
Serial.print("4");
delay(100);