Go Down

Topic: DAC MCP4822 with Arduino-Méga [resolved ] (Read 490 times) previous topic - next topic

AlienArea51

Oct 14, 2011, 01:41 pm Last Edit: Oct 14, 2011, 03:40 pm by AlienArea51 Reason: 1
HI
How to use the Mcp4822 with arduino méga ?
because this program works with the duemilanove.
By using these connections that does not work:
Quote
On the Arduino Mega, this is 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS).


Code: [Select]
#include <SPI.h>

const byte kGatePin = 2;
const byte SS_PIN = 10;

int trig=50;


void sendNote(int key) {
 int pitch = 0xa00L * key / 12;
digitalWrite(kGatePin, LOW);
   digitalWrite(SS_PIN, LOW);
 SPI.transfer(0x10 + (pitch >> 8));
 SPI.transfer(pitch & 0xff);
 digitalWrite(SS_PIN, HIGH);
delay(trig);

 digitalWrite(kGatePin, HIGH);
 delay(5);
}

void setup() {
 pinMode(kGatePin, OUTPUT);
 pinMode (SS_PIN, OUTPUT);
  SPI.begin();
}

void loop() {
   sendNote(0);
 sendNote(12);
 sendNote(11);
 sendNote(12);
 sendNote(16);
 sendNote(12);
 sendNote(11);
 sendNote(12);

 sendNote(0);
 sendNote(12);
 sendNote(10);
 sendNote(12);
 sendNote(16);
 sendNote(12);
 sendNote(10);
 sendNote(12);

 sendNote(0);
 sendNote(12);
 sendNote(9);
 sendNote(12);
 sendNote(16);
 sendNote(12);
 sendNote(9);
 sendNote(12);

 sendNote(0);
 sendNote(12);
 sendNote(8);
 sendNote(12);
 sendNote(16);
 sendNote(12);
 sendNote(8);
 sendNote(12);
}


Tank
William
The truth is elsewhere !!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy