Editing Hack Notes CVA 090324

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 57: Line 57:
   for(int i = BitsCount; i >= 0; i--) {
   for(int i = BitsCount; i >= 0; i--) {
     digitalWrite(CLK_pin, LOW);
     digitalWrite(CLK_pin, LOW);
     if ((Value >> i) & 1) {
     if ((Value & 1 << i) == ( 1 << i)) {
       digitalWrite(DIO_pin, HIGH);
       digitalWrite(DIO_pin, HIGH);
       //Serial.print("1");
       //Serial.print("1");
Line 97: Line 97:
// the integer.
// the integer.
// see: http://en.wikipedia.org/wiki/Two%27s_complement
// see: http://en.wikipedia.org/wiki/Two%27s_complement
   if ((ShiftIn_result >> 11) & 1) {
   if ((ShiftIn_result & 1 << 11) == 1 << 11) {
     ShiftIn_result = (B11111000 << 8) | ShiftIn_result;  
     ShiftIn_result = (B11111000 << 8) | ShiftIn_result;  
   }
   }
Line 142: Line 142:


void loop() {
void loop() {
   if (millis() - serialTimer > 50 ) {
   if ((millis() - serialTimer) > 50 ) {


   //read compass and print data to lcd and serial out
   //read compass and print data to lcd and serial out
Line 167: Line 167:
   lcd.printIn(" ");
   lcd.printIn(" ");
   digitalWrite(EN_pin, HIGH); // ok deselect chip
   digitalWrite(EN_pin, HIGH); // ok deselect chip
   angle = 180 * (atan2(-Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!!
   angle = 180 * (atan2(-1 * Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!!
   Serial.print(angle); // print angle
   Serial.print(angle); // print angle
   sprintf(string, "%4d", angle);
   sprintf(string, "%4d", angle);
Line 300: Line 300:
   for(int i = BitsCount; i >= 0; i--) {
   for(int i = BitsCount; i >= 0; i--) {
     digitalWrite(CLK_pin, LOW);
     digitalWrite(CLK_pin, LOW);
     if ((Value >> i) & 1) {
     if ((Value & 1 << i) == ( 1 << i)) {
       digitalWrite(DIO_pin, HIGH);
       digitalWrite(DIO_pin, HIGH);
       //Serial.print("1");
       //Serial.print("1");
Line 340: Line 340:
// the integer.
// the integer.
// see: http://en.wikipedia.org/wiki/Two%27s_complement
// see: http://en.wikipedia.org/wiki/Two%27s_complement
   if ((ShiftIn_result >> 11) & 1) {
   if ((ShiftIn_result & 1 << 11) == 1 << 11) {
     ShiftIn_result = (B11111000 << 8) | ShiftIn_result;  
     ShiftIn_result = (B11111000 << 8) | ShiftIn_result;  
   }
   }
Line 385: Line 385:


void loop() {
void loop() {
   if (millis() - serialTimer > 2200 ) {
   if ((millis() - serialTimer) > 2200 ) {


   //read compass and print data to lcd and serial out
   //read compass and print data to lcd and serial out
Line 410: Line 410:
   lcd.printIn(" ");
   lcd.printIn(" ");
   digitalWrite(EN_pin, HIGH); // ok deselect chip
   digitalWrite(EN_pin, HIGH); // ok deselect chip
   angle = 180 * (atan2(-Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!!
   angle = 180 * (atan2(-1 * Y_Data , X_Data) / M_PI); // angle is atan( -y/x) !!!
   Serial.print(angle); // print angle
   Serial.print(angle); // print angle
   sprintf(string, "%4d", angle);
   sprintf(string, "%4d", angle);
Line 461: Line 461:
==Stuff that would have been nice to have==
==Stuff that would have been nice to have==
*"Third hand" for holding stuff while soldering.
*"Third hand" for holding stuff while soldering.
*Our RBBBs already! That's why we [[RBBB_ORDER_SIGN_UP|ordered them today]].
*Our RBBBs already! That's why we ordered them today.
 
[[Category:Sensebridge]]
Please note that all contributions to Noisebridge are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Noisebridge:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)