Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
ElectroSenseArduino/omat_test.pde at main · Sudomarko/ElectroSenseArduino · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Sudomarko
ElectroSenseArduino
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
ElectroSenseArduino
/
omat_test.pde
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
113 lines (90 loc) · 3.26 KB
main
Breadcrumbs
ElectroSenseArduino
/
omat_test.pde
Copy path
Top
File metadata and controls
Code
Blame
113 lines (90 loc) · 3.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
This example code is in the public domain.
import
processing.serial.*
;
import
processing.opengl.*
;
int
bgcolor;
//
Background color
int
fgcolor;
//
Fill color
Serial
myPort;
//
The serial port
int
[] serialInArray
=
new
int
[
225
];
//
Where we'll put what we receive
int
[] pastInArray
=
new
int
[
225
];
float
[][] colorTarget
=
new
float
[
3
][
255
];
float
[][] currentColor
=
new
float
[
3
][
155
];
PVector
[][] vertices
=
new
PVector
[
15
][
15
];
float
[] verticesTZ
=
new
float
[
15
];
float
w
=
20
;
float
ease
=
0.05
;
int
serialCount
=
0
;
//
A count of how many bytes we receive
int
xpos, ypos;
//
Starting position of the ball
boolean
firstContact
=
false
;
//
Whether we've heard from the microcontroller
int
tiempoant;
int
render
=
0
;
int
dif
=
0
;
void
setup
() {
size
(
960
,
960
,
OPENGL
);
//
Stage size
noStroke
();
//
No border on the next thing draw
//
Print a list of the serial ports, for debugging purposes:
println
(
Serial
.
list());
//
I know that the first port in the serial list on my mac
//
is always my FTDI adaptor, so I open Serial.list()[0].
//
On Windows machines, this generally opens COM1.
//
Open whatever port is the one you're using.
myPort
=
new
Serial
(
this
,
Serial
.
list()[
0
],
115200
);
for
(
int
j
=
0
; j
<
15
; j
++
) {
for
(
int
i
=
0
; i
<
15
; i
++
) {
vertices[i][j]
=
new
PVector
( i
*
w, j
*
w,
0
);
}
}
}
void
draw
() {
if
(render
==
1
) {
translate
(
width
/
6
,
100
);
rotateX
(
0.5
);
//
rotateX(PI/10);
background
(
0
);
for
(
int
j
=
0
; j
<
14
; j
++
) {
beginShape
(
QUAD_STRIP
);
for
(
int
i
=
0
; i
<
15
; i
++
) {
stroke
(
255
);
fill
(serialInArray[j
+
i],
0
,
0
);
float
x
=
i
*
width
*
0.5
;
float
y
=
j
*
height
*
0.5
;
verticesTZ[i]
=
serialInArray[j
+
i];
vertices[i][j]
.
z
+=
(verticesTZ[i]
-
vertices[i][j]
.
z)
*
ease;
vertex
( vertices[i][j]
.
x, vertices[i][j]
.
y, vertices[i][j]
.
z);
vertex
( vertices[i][j
+
1
]
.
x, vertices[i][j
+
1
]
.
y, vertices[i][j
+
1
]
.
z);
}
endShape
(
CLOSE
);
//
println();
}
render
=
0
;
}
}
void
serialEvent
(
Serial
myPort
) {
//
read a byte from the serial port:
int
inByte
=
myPort
.
read();
//
if this is the first byte received, and it's an A,
//
clear the serial buffer and note that you've
//
h
//
ad first contact from the microcontroller.
//
Otherwise, add the incoming byte to the array:
if
(firstContact
==
false
) {
if
(inByte
==
'
A
'
) {
myPort
.
clear();
//
clear the serial port buffer
firstContact
=
true
;
//
you've had first contact from the microcontroller
myPort
.
write(
'
A
'
);
//
ask for more
}
}
else
{
//
Add the latest byte from the serial port to array:
serialInArray[serialCount]
=
inByte;
serialCount
++
;
//
If we have 3 bytes:
if
(serialCount
>=
224
) {
println
(
millis
()
-
tiempoant);
tiempoant
=
millis
();
render
=
1
;
//
Send a capital A to request new sensor readings:
myPort
.
write(
'
A
'
);
//
Reset serialCount:
serialCount
=
0
;
}
}
}
You can’t perform that action at this time.