Pages: [1]   Go Down
Author Topic: DAC MCP4822 with Arduino-Méga [resolved ]  (Read 416 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 5
Posts: 687
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
« Last Edit: October 14, 2011, 08:40:38 am by AlienArea51 » Logged

The truth is elsewhere !!

Pages: [1]   Go Up
Jump to: