#include <Stepper.h>
#define STEPS 48
...
void servo() {
Stepper stepper(STEPS, 13, 12, 11, 10);
stepper.setSpeed(60);
stepper.step(1024);
delay(500);
}
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
VGAX vga;
vga.begin();
#include <VGAX.h>
#include "glyph.h"
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
#define in1 10
#define in2 11
#define in3 12
#define in4 13
double xVa, yVa, a3_copi;
void setup() {
}
void loop() {
output();
servo();
}
void servo() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
int dl = 5;
for (int i = 0; i < 200; i++) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(dl);
digitalWrite(in1, HIGH);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(dl);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(dl);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, HIGH);
delay(dl);
}
}
void output() {
VGAX vga;
Serial.println("Start");
boolean button = false;
boolean output = true;
vga.begin();
while (output) {
char stri[10];
static const char str[] PROGMEM = "Move on";
static const char str0[] PROGMEM = "X = ";
static const char str1[] PROGMEM = "Y = ";
static const char str2[] PROGMEM = "Tact = ";
static const char str3[] PROGMEM = "Yoke = ";
double a1 = (analogRead (A1) / 10) - 51;
double a2 = (analogRead (A2) / 10) - 51;
int a3 = analogRead (A5) / 10;
xVa += map(a1, -51, 51, -a3, a3) / 100.0;
yVa += map(a2, -51, 51, -a3, a3) / 100.0;
if ((a1 != 0) || (a2 != 0) || (a3_copi != a3)) {
a3_copi = a3;
vga.clear(BLACK);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str, 10, 0, RED);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str0, 10, 10, RED);
dtostrf(xVa, 3, 2, stri);
vgaPrint(stri, 30, 10, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str1, 10, 20, RED);
dtostrf(yVa, 3, 2, stri);
vgaPrint(stri, 30, 20, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str2, 60, 0, GREEN);
dtostrf(a3, 3, 2, stri);
vgaPrint(stri, 90, 0, GREEN, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str3, 60, 10, GREEN);
dtostrf(a1, 3, 2, stri);
vgaPrint(stri, 90, 10, GREEN, vga);
dtostrf(a2, 3, 2, stri);
vgaPrint(stri, 90, 20, GREEN, vga);
button = true;
} else {
if (button) {
vga.clear(BLACK);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str, 10, 0, RED);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str0, 10, 10, RED);
dtostrf(xVa, 3, 2, stri);
vgaPrint(stri, 30, 10, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str1, 10, 20, RED);
dtostrf(yVa, 3, 2, stri);
vgaPrint(stri, 30, 20, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str2, 60, 0, GREEN);
dtostrf(a3, 3, 2, stri);
vgaPrint(stri, 90, 0, GREEN, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str3, 60, 10, GREEN);
dtostrf(a1, 3, 2, stri);
vgaPrint(stri, 90, 10, GREEN, vga);
dtostrf(a2, 3, 2, stri);
vgaPrint(stri, 90, 20, GREEN, vga);
vga.delay(100);
dtostrf(0, 3, 2, stri);
vgaPrint(stri, 90, 10, GREEN, vga);
dtostrf(0, 3, 2, stri);
vgaPrint(stri, 90, 20, GREEN, vga);
button = false;
}
}
if (digitalRead(0) == LOW) {
static const char str0[] PROGMEM = "start";
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str0, 0, 0, GREEN);
delay(5000);
vga.end();
output = false;
}
vga.delay(100);
}
}
void vgaPrint(char * str, byte x, byte y, byte color, VGAX vga) {
vga.printSRAM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str, x, y, color);
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)MyThreadFunction, NULL, NULL, NULL);
Sleep(100);
hhh f;
f.aaa = 10;
}
};
DWORD WINAPI MyThreadFunction(LPVOID lpParam)
{
hhh f;
f.aaa = 5;
return 0;
}
#pragma once
ref class hhh
{
public:
static int aaa;
};