Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Serial Communication Arduino
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GRASP
Serial Communication Arduino
Commits
b2f8a624
"win32/git@gitlab.liu.se:irt/sleuthkit.git" did not exist on "26d617b89eb6159b91732950e74125f80d42e13c"
Commit
b2f8a624
authored
3 years ago
by
Ilona Szczot
Browse files
Options
Downloads
Patches
Plain Diff
Added new python script to test forces
parent
dd54834b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
send2arduino.py
+30
-0
30 additions, 0 deletions
send2arduino.py
with
30 additions
and
0 deletions
send2arduino.py
0 → 100644
+
30
−
0
View file @
b2f8a624
import
serial
import
time
TEST_VALUE
=
1000
SLEEP_SEC
=
5
# com port for arduiono usb
COM
=
"
COM4
"
# baudrate same as in arduino
BAUDRATE
=
115200
try
:
my_serial
=
serial
.
Serial
(
COM
,
baudrate
=
BAUDRATE
,
timeout
=
2
)
print
(
"
Device found
"
)
# translate to something that will be read by arduino
arg
=
bytes
(
str
(
int
(
TEST_VALUE
)),
'
utf8
'
,
'
ignore
'
)
+
b
'
\r
'
# send value to arduino serial
my_serial
.
write
(
arg
)
# hold that value for SLEEP_SEC
time
.
sleep
(
SLEEP_SEC
)
# release by sending negative value
arg
=
bytes
(
str
(
int
(
-
TEST_VALUE
)),
'
utf8
'
,
'
ignore
'
)
+
b
'
\r
'
# send to arduino serial
my_serial
.
write
(
arg
)
except
:
print
(
"
Problem finding device.
\n
Check your com port or device.
"
)
print
(
"
All Done
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment