Code for Arduino Due to get LED to change brightness isn't working

I’m trying to vary the brightness of an LED in a sinusoidal manner by modifying the code from the Arduino website ( ). My goal of this code is to get the LED to get repeatedly brighter and dimmer as soon as I hit the pushbutton, and to stop all function once I hit the pushbutton again. I uploaded my code but nothing happens.

I have one leg of the pushbutton connected to the 3.3V, another leg is connected to the PWM pin 2 and to a 10Kohm resistor which in turn is connected to GND. The DAC0 is connected to a 330 Ohm resistor, the LED is then connected in series to the 330 resistor and then to GND. (This is on an Arduino DUE board)

And this is my code, any help would be great.

// Establish Integers

const int maxWaveform = 1;
const int maxSamplesNum = 120;
const int oneHzSample = 1000000/maxSamplesNum;
const int button = 2;  // designated pin 2 for pushbutton
volatile int on = 0;  // will be used for the interrupt

int i = 0;
int sample;

// Establish Sine Table

static int waveformsTable[maxWaveform][maxSamplesNum] = 
    0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
    0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
    0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
    0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
    0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
    0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
    0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
    0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
    0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
    0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
    0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
    0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794

// Set output Resolution

void setup() {
  attachInterrupt(button, On_Off, CHANGE);  //Interrupt for pushbutton
  pinMode(button, INPUT);

// Write main code

void loop() {
  if(on == 0) {
  if(on == 1) {
    sample = oneHzSample;
    analogWrite(DAC0, waveformsTable[1][i]);
    if(i == maxSamplesNum)
      i = 0;

// Interrupt code so everytime button is pushed this should be executed
void On_Off() {
  if(on > 1) {
    on = 0;

What happens if you set the initial value of on to 1 ? Do you get any output ? If so, then the problem is with the interrupt or how it is triggered. You have chosen an odd way to set the on variable to either 0 or 1. Why not make it a boolean and then use on = !on; to flip the value ? Why the test for on == 0 when you do nothing whatever the result ?

You can't drive an LED like that on a Due. 1) there will not be enough voltage to turn on the LED as you don't get the full,swing out odd the DAC output. 2) there is not enough current capability from that output. People have blown up that pin using less of a load than that.