Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Problem with SPI.transfer() on: December 11, 2013, 10:24:53 pm
Hello I've been trying to initialize an SD card in SPI mode (yes I know there is a SD library) so that I can read the raw data from the card and hopefully recover some of the stuff that was on one of my cards that has corrupted. If I can't manage to save anything at least I'll learn a thing or two about SD cards in the process.

So the problem i've been having is that my code seems to halt after SPI.transfer() i've been troubleshooting by writing to the Serial console at different parts in the code

Code:
#include <SPI.h>


const int CS_PIN = 10;
const byte GO_IDLE_STATE[6] = {0x40,0x00,0x00,0x00,0x00,0x95};
const byte CARD_READY[6] = {0x41,0x00,0x00,0x00,0x00,0xFF};
const byte SET_BLOCK_SIZE[6] = {0x50,0x00,0x00,0x02,0x00,0xFF};
const byte READ_BLOCK[6] = {0x51,0x00,0x00,0x00,0x00,0xFF};


void setup(){
  Serial.begin(9600);
  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  SPI.begin();
}

void loop(){

      Serial.println("Initializing.....");
      for(int i = 0; i < 10; i++){
        SPI.transfer(0xFF); //these 10 SPI.transfer() s dont halt the code
      }
      SD_Command(GO_IDLE_STATE);
      SD_Command(CARD_READY);
      SD_Command(SET_BLOCK_SIZE);
      while(1){} //this is just to stop it so i can see what the output is
     

}

void repeatSPI(int num, byte data){
  for(int i = 0; i < num; i++){
    SPI.transfer(data);
  }
}

byte getSDResponse(){
  byte R = 0xFF;
  byte temp;
  for(int i = 0; i < 8; i++){
    if(R == 0xFF){
      R = SPI.transfer(0xFF); //the first time an SPI.transfer() call is made after the first loop the code halts
      temp = R;
    }
    else{
      temp = SPI.transfer(0xFF);
    }
    Serial.print(temp,HEX);
    if(i < 7){Serial.print(":");}
  }
  Serial.println();
  return R;
}

byte SD_Command(const byte cmd[]){
  byte temp;
  pinMode(CS_PIN, LOW);
  Serial.print("Sending Command:  ");
  for(int i = 0; i < 6; i++){
    Serial.print(cmd[i], HEX);
    if(i<5){
      Serial.print(":");
    }
  }
  Serial.println();
  for(int i = 0; i < 6; i++){
    shiftOut(11,13,MSBFIRST,cmd[i]); //I originally tried to get around the problem by using shiftOut instead of SPI.transfer()
  }
  temp = getSDResponse();
  pinMode(CS_PIN, HIGH);
  return temp;
}

any help would be appreciated thanks  smiley
2  Using Arduino / Networking, Protocols, and Devices / RF24 Library and Leonardo problem on: August 16, 2013, 10:46:29 pm
Hello smiley I'm having a problem getting the getting started sketch from the RF24 library working with my leonardo. according to this http://bit.ly/1cTUBmd (google groups) all i need to do is connect pins 5, 6, and 7 from the radio to the ICSP headers on my leonardo and make a few small changes in the code.

Adding this line:
Code:
while (!Serial) {}

after this:
Code:
Serial.begin(57600);

and changing this:
Code:
RF24 radio(9,10);

to this:
Code:
RF24 radio(8,10);

After that all i get is a blank serial monitor instead of the debug message that i am supposed to get [Tested and working on Arduino Uno]

Thanks in advance for your help  smiley-grin
3  Topics / Home Automation and Networked Objects / Re: Arduino and the internet? on: February 03, 2013, 10:56:21 am
Thanks for the quick responses, I guess I was looking at it the wrong way I dont think I'll have too much trouble getting it online now. Thanks again.
4  Topics / Device Hacking / Re: Xbox 360 support on: February 02, 2013, 12:49:18 pm
http://www.instructables.com/id/Diy-Xbox-wireless-controller-adapter-for-Pc/
this is an instructable i made on it a while ago the pictures aren't the best but it covers just about everything neccesary. you can get an rf module on ebay for 10 -15 $ and the diodes or voltage regulator are easy to come by online or at radioshack
5  Topics / Home Automation and Networked Objects / Arduino and the internet? on: February 02, 2013, 12:40:20 pm
Hi im a High school senior and i've been working on a home automation project for an internship. So far i have been able to get the arduino to serve a webpage and control relays based on input from the page (i also hooked up a lm34 temp sensor). Im ready to start testing it over the internet rather than my home network but i have been unable to find any guides / code examples that make the arduino accessable over the internet rather than just the local network. I've used the Webduino library for the server. Has anyone seen a decent guide/ code example for getting the arduino on the internet? thanks.
6  Topics / Home Automation and Networked Objects / Re: Arduino webserver question on: January 26, 2013, 11:26:35 am
Thanks that should help  smiley-lol
7  Topics / Home Automation and Networked Objects / Arduino webserver question on: January 25, 2013, 06:32:24 pm
Hi im a high school senior working on a small home automation project for an internship. I was wondering if  it was possible to setup an arduino to serve webpages from .html files on an sd card. Basically my idea is to have a login page, a control page, and a log page showing when different users logged in and what they did. if it's possible do you know of a good tutorial for it? all i have been able to find are tutorials where the web pages were designed in the arduino sketch. Thanks.  smiley
8  Using Arduino / LEDs and Multiplexing / Re: MAX7219 LED matrix help on: November 27, 2012, 10:29:13 pm
Thanks again for all the help. After poking around with a logic probe with the help of my mentor from an internship i have at the Air Force Reasearch Labs at Griffis AFB we decided that the arduino was communicating properly i then went over the wiring again and this time i noticed that the wires for pins 13 -24 on the led matrix were shifted over one colomn on the bread board after i fixed that it still wasnt working and i found out i had the matrix upside down and that why the leds werent changing at all.  smiley-red
Thanks again.
9  Using Arduino / LEDs and Multiplexing / Re: MAX7219 LED matrix help on: November 26, 2012, 09:53:51 am
Thanks for the help ill check it out with a logic probe and breadboard the matrix like you suggested. The iset resististor is definately connected to 5v. ive uploaded the datasheet for the matrix if you wanted to take a look at it. Thanks again for the help.
10  Topics / Home Automation and Networked Objects / Re: Arduino Controller android app on: November 25, 2012, 04:36:32 pm
Thanks i was thinking about doing a home automation project (probably just lights) but i havent coded anything for android before so ive been putting it off this will definately help
11  Using Arduino / LEDs and Multiplexing / MAX7219 LED matrix help on: November 25, 2012, 04:13:30 pm
I am in the process of building an 8x48 led matrix to display messages on. (im planning on asking one of my friends to prom by leaving it in her locker). i'm trying to get the display working with only one 8x8 led matrix (they are 24 pin bi color matrixes), I have tried the LEDemomatrix example for the LEDcontrol library and the display does not change. I've checked my wiring and I can't find any problems there. My guess would be that the arduino is not communicating with my MAX7219 but I don't know how to solve the problem. I'm using a breadboard to test the circut on (if that matters) and I did remeber the two capacitors between +5v and GND, also Im using a 27k resistor for iset (my matrixes are rated for 2.2-2.5v at 20 miliamps) has anyone had a similar problem? Thanks.

here's the page for LEDcontrol   http://www.arduino.cc/playground/Main/LedControl
here's the page for the MAX72XX   http://arduino.cc/playground/Main/MAX72XXHardware

ive attached a word document with a table of what i have attached to each of the MAX7219's pins, i did not mention the capacitors in the document
Pages: [1]