forked from Seeed-Studio/Seeed_Arduino_AS5600
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add resultoutput function, mode = 0, output PWM, mode = 1 output analog
- Loading branch information
Showing
3 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <Wire.h> | ||
#include <AS5600.h> | ||
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE | ||
#define SERIAL SerialUSB | ||
#define SYS_VOL 3.3 | ||
#else | ||
#define SERIAL Serial | ||
#define SYS_VOL 5 | ||
#endif | ||
|
||
AMS_5600 ams5600; | ||
|
||
int ang, lang = 0; | ||
|
||
void setup() | ||
{ | ||
SERIAL.begin(115200); | ||
Wire.begin(); | ||
SERIAL.println(">>>>>>>>>>>>>>>>>>>>>>>>>>> "); | ||
if(ams5600.detectMagnet() == 0 ){ | ||
while(1){ | ||
if(ams5600.detectMagnet() == 1 ){ | ||
SERIAL.print("Current Magnitude: "); | ||
SERIAL.println(ams5600.getMagnitude()); | ||
break; | ||
} | ||
else{ | ||
SERIAL.println("Can not detect magnet"); | ||
} | ||
delay(1000); | ||
} | ||
} | ||
/* mode = 0, output PWM, mode = 1 output analog (full range from 0% to 100% between GND and VDD*/ | ||
ams5600.setOutPut(0); | ||
} | ||
|
||
void loop() | ||
{ | ||
} |