-
Notifications
You must be signed in to change notification settings - Fork 0
/
arduino
86 lines (85 loc) · 2.02 KB
/
arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Arduino Source Code
//Constants:
//const int ledPin = 3; //pin 3 has PWM funtion
const int flexPin1 = A7; // to read analog input from 1st flex sensor
const int flexPin2 = A6; // to read analog input from 2nd flex sensor
const int flexPin3 = A5; // to read analog input from 3rd flex sensor
const int flexPin4 = A4; // to read analog input from 4th flex sensor
const int flexPin5 = A3; // to read analog input from 5th flex sensor
//Variables:
int value1;
int value2;
int value3;
int value4;
int value5;
//values from 3 contact sensors
int pinx = 12;
int piny = 8;
int pinz = 10;
int xpin = A8; // x-axis of the accelerometer
int ypin = A9; // y-axis
int zpin = A10; // z-axis (only on 3-axis models)
//variables
int v1 =0;
int v2 = 0;
int v3 = 0;
int v4 = 0;
int v5 =0;
int v6=0;
int v7=0;
int v8=0;
int v9 =0 ;
void setup(){
Serial.begin(9600);
pinMode(pinx, INPUT);
digitalWrite(pinx, HIGH);
pinMode(piny, INPUT);
digitalWrite(piny, HIGH);
pinMode(pinz, INPUT);
digitalWrite(pinz, HIGH);
Serial.println("CLEARDATA
Serial.print("LABEL,F1,F2,F3,F4,F5,X,Y,Z,C1,C2");
Serial.println();}
void loop(){
value1 = analogRead(flexPin1);
value2 = analogRead(flexPin2);
value3 = analogRead(flexPin3);
value4 = analogRead(flexPin4);
value5 = analogRead(flexPin5);
v1 = analogRead(xpin);
v2 = map(v1, 0, 1023, 0, 255);
v3 = analogRead(ypin);
v4 = map(v3, 0, 1023, 0, 255);
v5 = analogRead(zpin);
v6 = map(v5, 0, 1023, 0, 255);
v7 = digitalRead(pinx);
v8 = digitalRead(piny);
v9= digitalRead(pinz);
//Print value
//value = map(value, 700, 900, 0, 255);//Map value 0-1023 to 0-255 (PWM)
Serial.print("DATA,TIME,");
Serial.print(value1);
Serial.print(",");
Serial.print(value2);
Serial.print(",");
Serial.print(value3);
Serial.print(",");
Serial.print(value4);
Serial.print(",");
Serial.print(value5);
Serial.print(",");
Serial.print(v2);
Serial.print(",");
Serial.print(v4);
Serial.print(",");
Serial.print(v6);
Serial.print(",");
Serial.print(v7);
Serial.print(",");
Serial.print(v8);
Serial.print(",");
Serial.print(v9);
Serial.println();
// delay before next reading:
delay(500);
}