Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
duino-coin/Arduino_Code/Arduino_Code.ino at master · hgecode/duino-coin · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
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 }}
hgecode
duino-coin
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
duino-coin
/
Arduino_Code
/
Arduino_Code.ino
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
80 lines (75 loc) · 3.57 KB
master
Breadcrumbs
duino-coin
/
Arduino_Code
/
Arduino_Code.ino
Copy path
Top
File metadata and controls
Code
Blame
80 lines (75 loc) · 3.57 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
//
////////////////////////////////////////////////////////
//
____ _ ____ _
//
| _ \ _ _(_)_ __ ___ / ___|___ (_)_ __
//
| | | | | | | | '_ \ / _ \ _____| | / _ \| | '_ \
// | |_| | |_| | | | | | (_) |_____| |__| (_) | | | | |
//
|____/ \__,_|_|_| |_|\___/ \____\___/|_|_| |_|
//
Code for Arduino boards v1.9
//
© Duino-Coin Community 2019-2021
//
Distributed under MIT License
//
//
If you don't know how to start,
//
visit our official website (duinocoin.com)
//
and navigate to the Getting Started page for help.
//
Happy mining!
//
////////////////////////////////////////////////////////
//
https://duinocoin.com - Official Website
//
https://github.com/revoxhere/duino-coin - Official GitHub
//
https://discord.gg/k48Ht5y - Official Discord server
//
https://github.com/revoxhere - @revox (Lead Duino-Coin developer)
//
https://github.com/daknuett - @daknuett (Thanks for help in library migration!
//
https://github.com/JoyBed - @JoyBed (Big thanks for many optimizations!)
//
////////////////////////////////////////////////////////
//
If uncommented, the count is reversed.
//
This allows to not repeat searching the same numbers twice if you have a second Arduino searching the "conventional" way
//
and possibly increase efficiency of multi-Arduino setup.
//
#define REVERSE_SEARCH
//
Include SHA1 part of cryptosuite2 library
#
include
"
sha1.h
"
String result;
//
Create globals
char
buffer[
64
] =
"
"
;
unsigned
int
iJob =
0
;
void
setup
() {
pinMode
(
LED_BUILTIN
,
OUTPUT
);
//
Prepare built-in led pin as output
Serial.
begin
(
115200
);
//
Open serial port
if
(Serial.
available
()) {
Serial.
println
(
"
ready
"
);
//
Send start word to miner program
}
}
void
loop
() {
String startStr = Serial.
readStringUntil
(
'
\n
'
);
if
(startStr ==
"
start
"
) {
//
Wait for start word, serial.available caused problems
Serial.
flush
();
//
Clear serial buffer
String hash = Serial.
readStringUntil
(
'
\n
'
);
//
Read hash
String job = Serial.
readStringUntil
(
'
\n
'
);
//
Read job
unsigned
int
diff = Serial.
parseInt
() *
100
+
1
;
//
Read difficulty
unsigned
long
StartTime =
micros
();
//
Start time measurement
#
ifdef
REVERSE_SEARCH
for
(
unsigned
int
iJob = diff; iJob >=
0
; iJob--) {
//
Reversed difficulty loop
#
else
for
(
unsigned
int
iJob =
0
; iJob < diff; iJob++) {
//
Difficulty loop
#endif
Sha1.
init
();
//
Create SHA1 hasher
Sha1.
print
(
String
(hash) +
String
(iJob));
uint8_t
* hash_bytes = Sha1.
result
();
//
Get result
for
(
int
i =
0
; i <
10
; i++) {
//
Cast result to array
for
(
int
i =
0
; i <
32
; i++) {
buffer[
2
* i] =
"
0123456789abcdef
"
[hash_bytes[i] >>
4
];
//
MSB to LSB (Depending on the address in hash_bytes)
//
Choose that from the given array of characters
buffer[
2
* i +
1
] =
"
0123456789abcdef
"
[hash_bytes[i] &
0xf
];
//
Retreve the value from address next spot over
}
}
result =
String
(buffer);
//
Convert and prepare array
result.
remove
(
40
);
//
First 40 characters are good, rest is garbage
if
(
String
(result) ==
String
(job)) {
//
If result is found
unsigned
long
EndTime =
micros
();
//
End time measurement
unsigned
long
ElapsedTime = EndTime - StartTime;
//
Calculate elapsed time
Serial.
println
(
String
(iJob) +
"
,
"
+
String
(ElapsedTime));
//
Send result back to the program with share time
PORTB
=
PORTB
|
B00100000
;
//
Turn on built-in led
delay
(
25
);
//
Wait a bit
PORTB
=
PORTB
&
B11011111
;
//
Turn off built-in led
break
;
//
Stop the loop and wait for more work
}
}
}
}
You can’t perform that action at this time.